Docker daemon doesn't start on boot on CoreOS

Solution 1:

sudo systemctl enable docker did the trick.

Solution 2:

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:

#cloud-config
coreos:
  units:
    - name: "docker.service"
      command: "start"
      enable: true

This will enable the docker service and start it on first and each boot.

Solution 3:

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:

[Unit]
Description=MyApp
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill busybox1
ExecStartPre=-/usr/bin/docker rm busybox1
ExecStartPre=/usr/bin/docker pull busybox
ExecStart=/usr/bin/docker run --name busybox1 busybox /bin/sh -c "trap 'exit 0' INT TERM; while true; do echo Hello World; sleep 1; done"

[Install]
WantedBy=multi-user.target

And have that service start automatically instead:

$ sudo systemctl enable /etc/systemd/system/myapp.service
$ sudo systemctl start hello.service

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.