-
Install docker-manger.conf and docker-instance.conf in /etc/init
-
Create a containers file in /etc/docker/ with the following format
name: image cmd
The name must be unique.
-
sudo service docker-manager start
-
You should now have upstart monitoring your container.
-
Use docker stop to kill your container and notice it gets restarted
Due to a bug in upstart (https://bugs.launchpad.net/upstart/+bug/568288) doing service docker-instance stop NAME=XXXX
fails to stop the instance. I'm not actually sure how to work around this.
Thanks for the starting point. I had two problems with your script. 1) as written, it prefers to run old containers rather than pulling new ones when appropriate. Deleting the 'start' clause fixes that. 2) One of my major reasons for using upstart is because it does logs better than docker. So I changed your
docker run -d
into anexec docker run
, and then usedps -l -q
in a post-start script to create the run file.