0

I have a docker compose file, which startes multiple docker containers in an order.

When executing docker compose up I would like to wait until the last container has sucessfully_completed

The --wait option only seems to wait until the docker container is running or healthy, which is too early.

I could add another dummy container waiting for my last container to sucessfully_completed but this seems a bit odd.

How can I wait for my last docker container of my docker compose to be completed, when running a docker compose file?

Herr Derb
  • 4,977
  • 5
  • 34
  • 62
  • Does this answer your question? [Docker Compose wait for container X before starting Y](https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y) – β.εηοιτ.βε Mar 02 '23 at 17:18
  • Actually it does not. The healthcheck is a tool to check if a container is up and running. I want to check if the last container of the docker compose up has completed and is not running anymore. – Herr Derb Mar 03 '23 at 07:28

1 Answers1

0

I have not found a way to do this with docker compose up -d

One solution is to follow your docker compose up -d command with something similar to:

while ! [[ $(curl --fail --silent http://127.0.0.1:8080/healthcheck) == 'Success' ]] ; do sleep 3; done
Steve Munini
  • 43
  • 1
  • 4