Skip to content

Instantly share code, notes, and snippets.

@gorbypark
Last active April 18, 2021 20:29
Show Gist options
  • Save gorbypark/627d67074e2db4ad8a9f2b83efdaad6e to your computer and use it in GitHub Desktop.
Save gorbypark/627d67074e2db4ad8a9f2b83efdaad6e to your computer and use it in GitHub Desktop.
Container Linux (CoreOS) and how to get docker to start on boot using ignition.

Container Linux (CoreOS), digitalocean and starting docker on boot

Container Linux (CoreOS) doesn't enable the docker systemd service by default. If you start a container with the --restart=always flag, for example, your container will not start up again automatically after a reboot. This may be desirable if you're running a cluster with an orchestration system that will handle this for you, but if you are using Container Linux with a single instance you might want your containers to start up by themselves. Of course you can easily enable to systemd service from the command line, but the best way is to pass an Ignition config file during the droplet creation process.

  1. Under the "Select additional options" section, select "User Data"
  2. In the box, paste the following Ignition config
{
  "ignition": { "version": "2.2.0" },
  "systemd": {
    "units": [{
      "name": "docker.service",
      "enable": true
    }]
  }
}

Now docker should start every time Container Linux (CoreOS) reboots and start any containers that have the appropriate --restart option set.

@cwitte4191
Copy link

This is a very helpful fix for an issue that has plagued me for a long time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment