How to auto restart a Docker container after a reboot in CoreOS?
For people want to auto restart a docker container, but didn't specify --restart
flag (default to 'no') while running it, you can use docker update command to add one of the following three other options:
- on-failure
- unless-stopped
- always
See this post for the details. People have problem with always
restart flag on, can consider using either on-failure
or unless-stopped
option.
CoreOS uses systemd to manage long running services:
- https://coreos.com/os/docs/latest/getting-started-with-systemd.html
What worked for me is to add --restart='always'
to the container {run -d ...} command
if you start the daemon with docker -d -r
, it will restart all containers that were running prior the daemon stopped.
This will become the default behavior in the next release.