Docker Community Forums

Share and learn in the Docker community.

Controlling starting up order in compose

beta

(Gayakwad) #1

We are using shell script to bring our local dev environment up. Shell script brings set of containers using compose in a particular order. It starts on container, waits for it to come up properly and then starts another. Below is the sample code

docker-compose up -d --remove-orphans kafka
waitForPort $DOCKER_HOST_IP $ZOOKEEPER_PORT
waitForPort $DOCKER_HOST_IP $KAFKA_PORT
docker-compose up -d --remove-orphans schema-registry
waitForPort $DOCKER_HOST_IP $SCHEMA_REGISTRY_PORT
docker-compose up -d --remove-orphans rest-proxy
waitForPort $DOCKER_HOST_IP $REST_PROXY_PORT

waitForPort loops on the nc status for port

This code stopped working when I updated to docker beta (for mac), prior to beta it used to work perfectly fine. It seems ports get enabled as soon as compose command is invoked.

Are there any patterns to handle this situation ? Currently I am checking for docker version and in case of beta I wait explicitly for some time. I don’t like this approach because it doesn’t ensure that service is actually up.

In case of services which we own we can introduce some kind of heath check and listen to it but for the services we don’t own we need to find some other solution.