0

There are 3 docker containers that need to be restarted automatically whenever the server reboot.

We can start the containers using restart policies, such as

sudo docker run --restart=always -d your_image

but because one container is linked to another, they need to be started in sequence.

Questioin: Is there a way to automatically restart Docker containers in sequence?

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

1 Answers1

0

Docker doesn't have an option for this, and doing so is an anti-pattern for microservices. Instead, each container should gracefully return errors when it's dependencies aren't available, or as a fall back, you can use something like a wait-for-it command in your container's entrypoint to wait for your dependencies to be available. I'd also recommend against using "links" and instead place all your services on their own docker network, letting the built in dns resolution handle service discovery for you.

BMitch
  • 231,797
  • 42
  • 475
  • 450