Docker Community Forums

Share and learn in the Docker community.

Check whether all images are started in docker compose


(Krishrub19) #1

Hi All,

I have few images to launch in docker compose and I want to start all the images by performing docker-compose up --detach (Detached mode). I want to wait till all the images from the docker compose YML file are started. Only then I want to launch another test program to connect to the Micro services that are started through docker compose. How do I check this through a program?

Thanks in Advance,
Krishna Ruban


(David Maze) #2

The most direct way is to use a tool like curl to make a minimal call to each of them.

Remember that there can be some delay between a container starting and its server actually being useful. (The database containers can take 10-15 seconds to do their first-time setup; anything based on Java has a famously long startup time.) So even if the container is “started” it doesn’t necessarily mean everything is set up to run your tests.

(I see that newer Docker has a HEALTHCHECK Dockerfile directive but I don’t know off hand how to see externally if a health check is passing. If you have another health-checking setup like via Consul or Kubernetes then you can ask that for status rather than directly probing the containers.)