Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto restart a Docker container after a reboot in CoreOS?

Tags:

docker

coreos

Assuming the Docker daemon is restarted automatically by whatever init.d or systemd like process when the OS is restarted, what is the preferred way to restart one or more Docker containers? For example I might have a number of web servers behind a reverse proxy or a database server.

like image 986
Richard Avatar asked Sep 13 '13 12:09

Richard


People also ask

How do I start docker containers automatically after reboot?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.

Does restarting docker restart containers?

no Do not automatically restart the container. (the default) on-failure Restart the container if it exits due to an error, which manifests as a non-zero exit code. always Always restart the container if it stops.

Does docker compose auto restart?

Like the restart Docker command, Docker Compose includes the restart property to restart containers automatically.


2 Answers

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.

like image 186
creack Avatar answered Oct 07 '22 04:10

creack


CoreOS uses systemd to manage long running services:

  • https://coreos.com/os/docs/latest/getting-started-with-systemd.html
like image 29
Mark O'Connor Avatar answered Oct 07 '22 04:10

Mark O'Connor