Add --restart feature. This restarts the container (killing any processes running in it)

This commit is contained in:
Adrian Kuschelyagi Malacoda 2021-07-09 12:47:04 -05:00
parent 2e16523810
commit f43ac055c2

View File

@ -93,6 +93,9 @@ def docker_commit (container, image_name):
def docker_rm (container):
call(["docker", "rm", "-f", container])
def docker_restart (container):
call(["docker", "restart", container])
def docker_rmi (container):
call(["docker", "rmi", "-f", container])
@ -151,6 +154,9 @@ def parse_command_line (command, config=None):
elif arg == "--rm":
config['actions'].append("rm")
command = command[1:]
elif arg == "--restart":
config['actions'].append("restart")
command = command[1:]
elif arg == "--rmi":
config['actions'].append("rmi")
command = command[1:]
@ -288,7 +294,11 @@ if actions:
target_image_name = get_generated_image_name(container_name)
log("Committing container: {} to image: {}", container_name, target_image_name)
docker_commit(container_name, target_image_name)
if "restart" in actions:
log("Restarting container: {}", container_name)
docker_restart(container_name)
if "rm" in actions:
log("Removing container: {}", container_name)
docker_rm(container_name)