From a0aeb8b0f144aedfb5d99fb00b08d45cd7259e25 Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Thu, 29 Jan 2015 16:26:44 -0500 Subject: [PATCH] If RUN does not exist, we shoudl create container and then start it --- atomic | 10 ++++++---- test.sh | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 test.sh diff --git a/atomic b/atomic index 9042514..2bc56a9 100755 --- a/atomic +++ b/atomic @@ -80,7 +80,7 @@ class Atomic(object): "--name", "NAME", "IMAGE" ] - RUN_ARGS = ["/usr/bin/docker", "run", + RUN_ARGS = ["/usr/bin/docker", "create", "-t", "-i", "--name", "NAME", @@ -224,8 +224,10 @@ class Atomic(object): "DATADIR":"/var/lib/%s" % self.name}, shell=True, stderr=subprocess.PIPE) else: + missing_RUN = False args = self._get_args("RUN") if not args: + missing_RUN = True args = self.RUN_ARGS + self._get_cmd() cmd = self.gen_cmd(args) @@ -233,9 +235,9 @@ class Atomic(object): subprocess.check_call(cmd, env={ "CONFDIR": "/etc/%s" % self.name, "LOGDIR": "/var/log/%s" % self.name, - "DATADIR":"/var/lib/%s" % self.name}, shell=True, stderr=subprocess.PIPE) - if self.command: - return subprocess.check_call(["/usr/bin/docker", "exec", "-t", "-i", self.name] + self.command) + "DATADIR":"/var/lib/%s" % self.name}, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + if missing_RUN: + self._start() def _rpmostree(self, *args): os.execl("/usr/bin/rpm-ostree", "rpm-ostree", *args) diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..76d1b23 --- /dev/null +++ b/test.sh @@ -0,0 +1,19 @@ +#!/bin/sh -x -e +atomic uninstall busybox +atomic install busybox +atomic uninstall busybox +atomic run --spc busybox /bin/ps +atomic run busybox /bin/ps +atomic run busybox /bin/sh +cat > Dockerfile <