Services in Docker compose files can have dependencies attached to them, normally for checking the condition of one or more dependent services, i.e. database servers or supporting services.
Example:
traefik:
isolation: ${TRAEFIK_ISOLATION}
image: ${TRAEFIK_IMAGE}
command:
- "--ping"
- "--api.insecure=true"
- "--providers.docker.endpoint=npipe:////./pipe/docker_engine"
- "--providers.docker.exposedByDefault=false"
- "--providers.file.directory=C:/etc/traefik/config/dynamic"
- "--entryPoints.websecure.address=:443"
- "--entryPoints.websecure.forwardedHeaders.insecure"
ports:
- "443:443"
- "8079:8080"
healthcheck:
test: ["CMD", "traefik", "healthcheck", "--ping"]
volumes:
- source: \\.\pipe\docker_engine
target: \\.\pipe\docker_engine
type: npipe
- ./traefik:C:/etc/traefik
depends_on:
id:
condition: service_healthy
cm:
condition: service_healthy
Here we have an entry for the Traefik load balancer service which traffics network requests to the respective destinations (https://traefik.io/). See the "depends-on", which shows dependency on the health of the CM and ID service instances.
A few notes about dependency tracing.
Always start at the "depends-on" section for the affected service in the compose file and work you way down. In one instance, I had an error with spinning up a 10.2 instance. Tracing involved starting on the top entry which was traefik.
Always good idea to look at the logs of all your containers either through VSCode or Docker Desktop.
VSCode
* Docker Desktop
From these logs we can diagnose failing services or errors to track down.
Stay tuned for the next tip!