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
$ docker run -d --link aaaaa B

This works just fine. If container “aaaaa” is not available, docker won’t let me start container of image B

  • Sporadic Robolectric test failures when running inside Docker container
  • Atomic, Docker 1.10 and Openshift Origin 1.2 incompatibility
  • npm update failed in docker
  • Uncaught exception Failure(“input_value: bad bigarray kind”) - Unison on Windows and Mgt Development Environment
  • Multiple versions of PHP through Nginx in Docker
  • CentOS disable service (docker) before boot?
  • # pseudo, Setup2
    $ docker run -d --link aaaaa B
    docker: Error response from daemon: Cannot link to a non running container

    Just fine.

    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?

  • failed to create symbolic/hard link in volume in docker on windows 7
  • How to scale a NodeJS stateful application
  • Nginx Docker's container : set default home page with a custom index.html
  • Filesystems content of docker container on host
  • Docker pull/push using private registry without prefixing
  • File not found in docker container
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.