>_ IzzyLab

Hands-on task

This task is step 15 of the course “Docker networking”

A three-container stack: find the break

hard~25 min

A shop stack: web (storefront) → api → db, all on izzylab/minihttp:1. The storefront is published on the server's 127.0.0.1:8080, web and api live in the front network, the database is in the back network, and db must not be reachable from web.

After a move the stack doesn't work: curl http://127.0.0.1:8080/call doesn't answer. Walk the chain, find all the breaks and fix them so that:

  • curl http://127.0.0.1:8080/call answers web -> api ok;
  • api's /call gets an answer from db;
  • web is published only on 127.0.0.1:8080, and db can't be reached from web.

Don't touch db or its settings — don't recreate or restart it. web and api may be recreated or reconnected with the same names, image and NAME.

The lab has its own Docker with no internet access; the images are already loaded: izzylab/minihttp:1, alpine:3.21, busybox:1.36, nginx:1.27-alpine. izzylab/minihttp is a tiny HTTP service on port 8080: GET / answers <NAME> ok, GET /call itself goes to http://<UPSTREAM>/ and answers <NAME> -> <the neighbor's reply> (or 502), GET /env shows its settings. It is configured with the environment variables NAME, PORT, BIND (the address it listens on) and UPSTREAM.

What you'll practise:
  • docker troubleshooting
  • docker network
  • port publishing

Topic breakdown

When a chain of containers doesn't answer, guessing is pointless — you look for the break link by link, from the client to the database. For each link there are three questions: does the server listen where the client knocks (the port inside the container, the address 0.0.0.0 or 127.0.0.1); can the client see the server over the network (a shared Docker network, the right name); is the address in the client's settings right (environment variables, config). Publishing with -p is responsible only for the way in from the host: it links a host port to a container port, and if the right-hand port is wrong, there's silence from outside while the service is healthy. Usually there are several faults, and fixing one reveals the next.

What's checked

  1. db is running, not recreated or restarted
  2. From the server, 127.0.0.1:8080/call: the storefront gets api's answer
  3. api gets an answer from db
  4. web is published only on 127.0.0.1:8080
  5. From web, db can't be reached — neither by name nor by IP

What it looks like