Say I have several docker services using swarm defined as such:
version : '3' services: server: image : my_server:latest deploy: replicas: 5 restart_policy: any database: image : my_db:latest deploy: replicas: 5 restart_policy: any logs: image : my_logger:latest deploy: replicas: 1 restart_policy: any
I then deploy this as a docker-stack as such. The services are server, database and logs. I make great use of the network abstractions provided by docker swarm, but my failure-case is a bit undockerish.
*In this case when all containers in database fail, then I want the entire stack to be shutdown or otherwise made unavailable*. Is there any built-in way to accomplish this task? Does the concept of a stack exist in a way for the individual services to access?
This question can be alternatively answered with a generalization : "How, with built-in docker features, can I be made aware of container failure"? Because I'm assuming there is no way to do exactly what I am asking.