1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-05 18:45:01 +01:00

If RUN does not exist, we shoudl create container and then start it

This commit is contained in:
Dan Walsh
2015-01-29 16:26:44 -05:00
parent 3885396a25
commit a0aeb8b0f1
2 changed files with 25 additions and 4 deletions

10
atomic
View File

@@ -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)

19
test.sh Normal file
View File

@@ -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 <<EOF
FROM busybox
LABEL RUN /usr/bin/docker run -ti --rm IMAGE /bin/echo RUN
LABEL INSTALL /usr/bin/docker run -ti --rm IMAGE /bin/echo INSTALL
LABEL UNINSTALL /usr/bin/docker run -ti --rm IMAGE /bin/echo UNINSTALL
EOF
docker build -t atomic_busybox .
atomic run atomic_busybox
atomic install atomic_busybox
atomic uninstall atomic_busybox
rm -f Dockerfile
atomic uninstall busybox