Add --rmi command that removes the generated image.
This commit is contained in:
parent
71fe46e881
commit
b1878aef1b
@ -29,6 +29,9 @@ Runs command as root, instead of current user.
|
||||
### --rm
|
||||
Removes the specified container.
|
||||
|
||||
### --rmi
|
||||
Removes image generated by the `otherworld` script (`image_$CONTAINER_NAME`)
|
||||
|
||||
### --commit
|
||||
Commits the container to an image named `image_$CONTAINER_NAME`.
|
||||
|
||||
|
12
otherworld
12
otherworld
@ -72,6 +72,9 @@ def docker_commit (container, image_name):
|
||||
def docker_rm (container):
|
||||
call(["docker", "rm", "-f", container])
|
||||
|
||||
def docker_rmi (container):
|
||||
call(["docker", "rmi", "-f", container])
|
||||
|
||||
def docker_build (build_path, options, image_name):
|
||||
check_call(["docker", "build"] + options + ["-t", image_name, build_path])
|
||||
return image_name
|
||||
@ -132,6 +135,9 @@ while len(command) > 0:
|
||||
elif arg == "--rm":
|
||||
actions.append("rm")
|
||||
command = command[1:]
|
||||
elif arg == "--rmi":
|
||||
actions.append("rmi")
|
||||
command = command[1:]
|
||||
elif arg == "--commit":
|
||||
actions.append("commit")
|
||||
command = command[1:]
|
||||
@ -173,6 +179,12 @@ if actions:
|
||||
print(f">> Removing container: {container_name}")
|
||||
docker_rm(container_name)
|
||||
|
||||
if "rmi" in actions:
|
||||
target_image_name = get_generated_image_name(container_name)
|
||||
if not quiet:
|
||||
print(f">> Removing image: {target_image_name}")
|
||||
docker_rmi(target_image_name)
|
||||
|
||||
if not command:
|
||||
sys.exit(0)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user