aboutsummaryrefslogtreecommitdiffstats
path: root/docker/docker-toool
diff options
context:
space:
mode:
authorIan Main <imain@redhat.com>2017-06-08 19:09:08 -0400
committerIan Main <imain@redhat.com>2017-06-08 19:09:08 -0400
commit3df4efff612a12a8ff50e274ed2a29a79964671a (patch)
treead69301b78eaf07f219444523709f76d8181f8e2 /docker/docker-toool
parentd01de0e985f0b8ed9a65a303c233ebb49d47886e (diff)
Add detach to docker-toool
This lets you rerun the container as it was before killing it. Change-Id: I12b8a1f7058bab621d68aa0e55b3be3e87854574
Diffstat (limited to 'docker/docker-toool')
-rwxr-xr-xdocker/docker-toool16
1 files changed, 10 insertions, 6 deletions
diff --git a/docker/docker-toool b/docker/docker-toool
index 36aba4a7..3132f8e7 100755
--- a/docker/docker-toool
+++ b/docker/docker-toool
@@ -69,10 +69,15 @@ def parse_opts(argv):
action='store_true',
help="""Start docker container interactively (-ti).""",
default=False)
+ parser.add_argument('-d', '--detach',
+ action='store_true',
+ help="""Start container detached.""",
+ default=False)
opts = parser.parse_args(argv[1:])
return opts
+
def docker_arg_map(key, value):
value = str(value).encode('ascii', 'ignore')
return {
@@ -81,12 +86,12 @@ def docker_arg_map(key, value):
'net': "--net=%s" % value,
'pid': "--pid=%s" % value,
'privileged': "--privileged=%s" % value.lower(),
- #'restart': "--restart=%s" % "false",
'user': "--user=%s" % value,
'volumes': "--volume=%s" % value,
'volumes_from': "--volumes-from=%s" % value,
}.get(key, None)
+
def run_docker_container(opts, container_name):
container_found = False
@@ -139,13 +144,15 @@ def run_docker_container(opts, container_name):
if opts.user:
continue
arg = docker_arg_map(container_data,
- json_data[step][container][container_data])
+ json_data[step][container][container_data])
if arg:
cmd.append(arg)
if opts.user:
cmd.append('--user')
cmd.append(opts.user)
+ if opts.detach:
+ cmd.append('--detach')
if opts.interactive:
cmd.append('-ti')
# May as well remove it when we're done too
@@ -164,19 +171,17 @@ def run_docker_container(opts, container_name):
if not container_found:
print("Container '%s' not found!" % container_name)
+
def list_docker_containers(opts):
- print opts
with open(opts.config) as f:
json_data = json.load(f)
for step in (json_data or []):
if step is None:
continue
- print step
for container in (json_data[step] or []):
print('\tcontainer: %s' % container)
for container_data in (json_data[step][container] or []):
- #print('\t\tcontainer_data: %s' % container_data)
if container_data == "start_order":
print('\t\tstart_order: %s' % json_data[step][container][container_data])
@@ -186,4 +191,3 @@ if opts.container:
run_docker_container(opts, opts.container)
else:
list_docker_containers(opts)
-