Containers: Docker, Compose and Swarm

Intermediate

Your first Compose stack

The shop runs a front (nginx), an API, PostgreSQL and Redis. A first compose.yaml starts everything, but it publishes the database and the cache on the server's public address. Only the front may be reachable from the internet, and the front must not even see the database.

nginx serves the site and forwards /api/ to the API. The test runs docker compose up -d --build, opens http://<server>/api/products every minute and, halfway, a scanner probes ports 3000, 5432 and 6379.

What your server must hold

  • Availability ≥ 99 %
  • No database or cache port open to the internet
  • Ports published on the server = 1
  • The front cannot reach the database

What you will master