diff --git a/otherworld b/otherworld index 4114ff7..2444c69 100755 --- a/otherworld +++ b/otherworld @@ -119,6 +119,8 @@ command_user = user user_volumes = USER_VOLUMES pull = False +actions = [] + command_env = {} quiet = False @@ -128,16 +130,11 @@ while len(command) > 0: command = command[1:] quiet = True elif arg == "--rm": - if not quiet: - print(f">> Removing container: {container_name}") - docker_rm(container_name) - sys.exit(0) + actions.append("rm") + command = command[1:] elif arg == "--commit": - image_name = get_generated_image_name(container_name) - if not quiet: - print(f">> Committing container: {container_name} to image: {image_name}") - docker_commit(container_name, image_name) - sys.exit(0) + actions.append("commit") + command = command[1:] elif arg == "--sudo": command_user = "root" command = command[1:] @@ -164,7 +161,22 @@ while len(command) > 0: else: break -if len(command) == 0: +if actions: + if "commit" in actions: + target_image_name = get_generated_image_name(container_name) + if not quiet: + print(f">> Committing container: {container_name} to image: {target_image_name}") + docker_commit(container_name, target_image_name) + + if "rm" in actions: + if not quiet: + print(f">> Removing container: {container_name}") + docker_rm(container_name) + + if not command: + sys.exit(0) + +if not command: command = DEFAULT_COMMAND container = None