>_ IzzyLab

Hands-on task

This task is step 14 of the course “CI/CD: pipelines and docker compose”

docker-compose file

medium~7 min

Write /root/docker-compose.yml with two services: web (image nginx) and db (image postgres:16), where web depends on db (depends_on). The file must conform to the Compose Specification schema — run yamlschema compose /root/docker-compose.yml to see the errors.

What you'll practise:
  • docker-compose
  • services
  • depends_on
  • images and tags
  • yaml

Topic breakdown

docker-compose describes a set of containers under the services: key — a dictionary where the key is the service name, and inside there's at least image:; services join a shared network and reach each other by service name as a host. depends_on controls only container startup order, but does not guarantee that the service inside is already ready to accept connections — for real readiness you need a healthcheck with the extended form of the dependency. Watch the exact service name in the dependency and don't forget the version tag on the image where the task requires it.

What's checked

  1. the file passes the Compose schema
  2. web service on nginx
  3. web depends on db
  4. db service on postgres:16

What it looks like