I'm trying to deploy 3 Docker containers, having a dependency relation amongst them (A -> B -> C). Now, each container is supposed to run an Akka-Spray instance, on top of a JVM instance.

The problem is: following usual orchestration approaches, container A has been started but the web server hasn't had time to boot up. If it isn't up and running before container B is operational, container B will never catch up and so forth, with C.

I've been trying the following approach lately: share a data volume between containers; after the web server is ready, a helper script will create an empty file in the volume; run a script (through an Upstart service) that looks for an empty file to show up and fires up the next container.

However, using a service is most likely the cause to this issue: running

sudo docker run -d -it --name=backend -v ~/docker-test/:/docker-test -v ~/aux/:/aux ubuntu /bin/bash -c "</path/to/test/script>"

works fine when done simply in command line, but fails randomly in the script executed by the Upstart service (receive message "/bin/bash </path/to/test/script> : no such file or directory").

Anyone's come across this, as well? I'd gratefully welcome any suggestions to overcome this.


Why not look at a purpose-built docker orchestrator like flynn, deis, shipyard, etc.?

Quite a list here


One option is to just wait until the remote network port is open, which indicates that the web server has started. Code below is based on this thread on SuperUser

SERVICE_IP=`sudo docker inspect -f \"{{.NetworkSettings.IPAddress}}\" $CONTAINER_NAME`
while ! nc -vz \$SERVICE_IP \$SERVICE_PORT; do sleep 1; done

This can be combined with a container build orchestrator (if that orchestrator doesn't natively support waiting for "container port is up" - I don't know what is available in that direction).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.