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

  • Advantages/Disadvantages of Running Jenkins Slaves for Dev/Test/Prod?
  • convert a Windows solution into windows docker containers
  • Unhandled promise rejection in Docker with 'opn' npm module
  • PhpStorm runs only local PHPUnit configuration. How to force it to use remote (Docker)?
  • docker speeds up python, why?
  • How to support interactive /bin/bash in docker exec command using python dockerpy module on windows?
  • # 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?

  • ImportError: cannot import name <package> in pods while restarting pod fixes
  • Adding standard CA roots to busybox docker image
  • Docker: transaction check error
  • Unable to use variable substitution in docker-compose
  • How to create windows docker image with VS test agents?
  • Jersey UniformInterfaceException when doing a POST with docker-client
  • 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.