1

Is it possible to restart a container if another container fails and restarts?

I have a server container and multiple client containers, I want to have it that if the server container fails and restarts, that one of the client containers restarts as well.

I've already used the restart policies (always, on-failure etc.) but this would be linking two containers and triggering the restart of container A if container B restarts.

Martaer
  • 45
  • 1
  • 1
  • 6
  • I don't think Compose can do this, but it also seems like a little bit of an odd requirement. How would you do it without Compose? How would you do it if the servers and clients were on different hosts? – David Maze Oct 19 '20 at 19:11

1 Answers1

0

This question seems to be quite similar, if not duplicate, of this one.

TL;DR: There has been a shift from defining complex restart policies in docker/docker-compose superseded by explicitly checking for dependencies from within your service so it is deployment agnostic. Therefore, the recommendation is to create specific checks within the container that 'depends' on other services and crash properly when they are not met so that a simple restart: always policy is all that is needed.

Raphael Guzman
  • 220
  • 2
  • 7