Is there a way to stop a docker container, if a linked/upstream container is gone?
In my use case, I am having two docker-images ‘A’ and ‘B’, where ‘B’ kind of relies on an exposed port of container A.
# pseudo, Setup1 $ docker run -d A aaaaa $ docker run -d --link aaaaa B bbbbb
This works just fine. If container “aaaaa” is not available, docker won’t let me start container of image B
# pseudo, Setup2 $ docker run -d --link aaaaa B docker: Error response from daemon: Cannot link to a non running container
Now, in my “Setup1”, I am stopping container “aaaaa”. Container “bbbbb” will just keep running. In my use case, I would like to stop this “dependent” container now. How can I achieve that?
One Solution collect form web for “Is there a way to stop a docker container, if a linked/upstream container is gone?”
Docker 1.12. introduces HEALTHCHECK. As an ugly workaround, it works to place a killall or similar in the HEALTHCHECK-script.
Maybe you are searching for docker-compose -> depends on.