Docker – running a docker container on upstart on Amazon Linux isn’t working

amazon ec2dockerupstart

I'm trying to get my container to run on startup using upstart.

As the tutorial said – I created /etc/init/nginx_server.conf

description "Nginx docker"
author "Me"
start on filesystem and started docker
stop on runlevel [!2345]
  /usr/bin/docker run -d -p 80:80 test_server
end script

Running of latest Amazon linux (amzn-ami-hvm-2015.03.0.x86_64-gp2)

The container isn't running at all (running docker ps -a doesn't show it at all)

Best Answer

On Amazon Linux, the Docker daemon is started with an init.d script, not an Upstart script. In your Upstart script you're trying to signal the startup when the docker service starts (..started docker). This will only work if the docker init script is an Upstart script.

You can add initctl emit docker-started to the docker init.d script and then trigger your Upstart service config file with that event (ie. start on docker-started)