Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Using instructions for Docker auto-start on Linode VPS running Ubuntu 12.04 and Docker 0.8.1, the specified container does not start on reboot.

Once booted, I am able to

~$ sudo start [service-name]

and everything goes as planned, but I would also like to container to restart after a reboot.

Is the script in the tutorial not designed to handle reboots?

/etc/default/docker file contains one line:

DOCKER_OPTS="-r=false"

/etc/init/service-name.conf is straight from the docker page:

description "service description"                                                                                                            
author "me"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
    # Wait for docker to finish starting up first.
    FILE=/var/run/docker.sock
    while [ ! -e $FILE ] ; do
        inotifywait -t 2 -e create $(dirname $FILE)
    done
    /usr/bin/docker start -a db5e61a9afa8
end script
share|improve this question
2  
What are the contents of your upstart script and /etc/default/docker? –  Bruno Pereira Mar 7 at 14:10
add comment

3 Answers 3

up vote 2 down vote accepted

At some point over the past couple of months, the upstart script in the tutorial was changed to remove the loop to wait for docker to start. I removed the loop from my upstart scripts and my containers now restart correctly after a reboot.

My /etc/init/service-name.conf script now looks like this:

description "service description"                                                                                                            
author "me"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
    /usr/bin/docker start -a db5e61a9afa8
end script

I'm not sure what was wrong with that loop. Maybe it was pointing to the wrong file on my system, although I didn't make any changes to the default docker install. For now, I'm just happy the fix involved code removal instead of some complicated work-around.

share|improve this answer
    
It'd be more upstart-ish to change the docker job to emit a signal (docker-started) and have that signal trigger the container jobs to start. –  MikeyB May 4 at 18:00
    
You cannot stop the container this way by issuing command stop service-name. I am facing this issue :( –  Ahmed Al Hafoudh Jul 4 at 22:19
add comment

I am using Ubuntu 13.10 as the host and I had the same issue. I found that docker installs a rc script for docker in /etc/init.d/docker and at the same time installs an upstart script at /etc/init/docker.conf. I just had to remove the rc script /etc/init.d/docker for this issue to go away.

Hope this works for you as well.

share|improve this answer
    
Sadly, this one did not work for me. –  jody Apr 16 at 0:56
add comment
DOCKER_OPTS="-r=false"

This means: Don't restart previously running containers.

Remove the -r option or change it to true.

share|improve this answer
1  
Right, but the point is to have upstart handle container restarts, not the docker daemon. If the docker daemon starts the container on reboot, the process can't be managed by upstart. –  jody May 4 at 14:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.