docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.03k stars 5.23k forks source link

depends_on or run_it_also? #4191

Closed onekit closed 7 years ago

onekit commented 7 years ago

Usually, if I launch docker-compose up -d, it will build all images, then create all of them in order mentioned in depends_on chain of docker-compose.yml.

What if approach with launching one by one will let remove "wait-for-it.sh" scripts. Time of start MySQL is near 5 minutes. Build of container usually takes even more.

Not important to know when container has been started. Much more important to know when service become is up and ready to work.

  1. Change order of build & create in docker-compose. Allow order, not only build 1, build 2, build 3, create 1, create2, create3, but build1&create1, build3&create3, build2&create2.
  2. Upgrade depends_on for waiting opening port (this data exists in docker-compose.yml) while ! curl --output /dev/null --silent --head --fail http://172.25.0.1:3306; do sleep 1 && echo -n .; done;

Finally we have time economy, cause while one container is building, previous already start to initialize. It allow put logic of Symfony project with Fixtures loading after MySQL is up.

onekit commented 7 years ago

Currently I deal with it that way: http://1kit.net/2016/12/04/docker-compose-depends_on/

But for sure we need new layer to keep in order running services (not containers, but services). Who cares about time of container is up? Much more important to know when service is up. If we decide to call it services, so we need to care about it as services. We can't blame service for something, till it not started yet. And we need to avoid wasting time and traffic for empty tries connect to not yet launched service.

We use "depends_on" and still want to require from services independent behaviors?

shin- commented 7 years ago

Healthcheck dependencies answer this need and were added in Compose 1.10