ajeeshpu
ajeeshpu

Reputation: 300

How do we set docker containers to restart on reboot and on-failure?

I would like the docker containers to come up

  1. On host reboot or when docker is restarted on host
  2. On failure with maximum retries .

I am aware that the docker restart policies unless-stopped and always are in the same direction but I would want them to fail after maximum retries.

Thinking of below steps as a solution

  1. No restart policy on docker containers
  2. systemd-docker to restart containers on-failure and enabled on reboot.

is there a better way to do this?

Upvotes: 2

Views: 751

Answers (1)

VonC
VonC

Reputation: 1323973

I would like the docker containers to come up On host reboot or when docker is restarted on host

This is not a complete answer, but know that docker 1.12 will add a daemonless container mode
(PR 23213):

Daemonless Containers

Starting with Docker 1.12 containers can run without Docker or containerd running.
This allows the Docker daemon to exit, be upgraded, or recover from a crash without affecting running containers on the system.

To enable this functionality you need to add the --live-restore flag when launching dockerd. This will ensure that Docker does not kill containers on graceful shutdown or on restart leaving the containers running.

Upvotes: 1

Related Questions