Closed onekit closed 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?
Healthcheck dependencies answer this need and were added in Compose 1.10
Usually, if I launch
docker-compose up -d
, it will build all images, then create all of them in order mentioned independs_on
chain ofdocker-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.
docker-compose
. Allow order, not onlybuild 1, build 2, build 3, create 1, create2, create3
, butbuild1&create1, build3&create3, build2&create2
.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.