I have an upstart script (say, /etc/init/dtest.conf
)
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
DID=$(docker.io run -d ubuntu /bin/bash -c "echo Starting;sleep 20;echo Stopping")
docker.io attach $DID
end script
When issuing start dtest
, the upstart logs show the proper cycle of "Starting ... Stopping" forever.
However, if I issue a stop dtest
, then it appears to exit properly, but the container will run for the remainder of the sleep time (as evidenced by running docker.io ps
every second).
Shouldn't there be an easy way to run a docker image in a container with upstart and have its lifecycle be managed there?
My ideal script would be something like this:
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec docker.io run -d ubuntu /bin/bash -c "echo Starting;sleep 20;echo Stopping"
Environment: This is on AWS, using Ubuntu 14.04 in a T2.micro, with apt-get install -y docker.io
being the only thing installed