I have a vanilla install of CoreOS (835.9.0) and it doesn't start the docker daemon on startup. It only starts when I SSH in and do eg docker ps
.
How can i make the docker daemon automatically start on system boot?
When i say the docker daemon, i mean ps -ef | grep docker
shows no processes until after i do docker ps
sudo systemctl enable docker
did the trick.This is a bit old now, but I have started using cloud-init to do this on all new servers. I have a saved cloud-init script I use for all my servers. Part of it contains:
This will enable the docker service and start it on first and each boot.
As already explained in this comment by Rob, docker is socket activated. That means that the deamon does not start unless it is called. The existing answers here work, but CoreOS recommends a different approach.
The recommended way to do this, according to the CoreOS documentation is to create a service for your own app which in turn requires the Docker service:
/etc/systemd/system/myapp.service:
And have that service start automatically instead:
The example use-case is to update the container to the latest version once the service starts and the advanced example also registers the service in etcd. Read the CoreOS documentation for more background information.
I'm using Docker Swarm, so I don't have a specific app for systemd to be responsible for... I just need docker to start on boot. This is the solution I worked out.
Put this
/etc/systemd/system/poke-docker.service
:And then just
systemctl enable poke-docker
to set it up to trigger on each boot, near the end of the startup sequence. Thedocker version
command talks to the docker daemon, triggering the socket and starting the docker service itself.I tried the
systemctl enable docker
trick in the other answer, and while it worked at first, it appears to have caused a thundering herd situation of some sort where docker was apparently trying to do a whole lot and failing miserably. I suspect this is the "blocking the boot chain" behavior mentioned in the comments there.