>_ IzzyLab

Hands-on task

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

The wrong neighbor address in environment variables

medium~12 min

The storefront frontend in the store network is published on the server's 127.0.0.1:8080, and curl http://127.0.0.1:8080/call answers 502: the storefront can't reach the catalog. The catalog container itself is alive.

The storefront takes the catalog's address from UPSTREAM in /root/frontend/frontend.env. Find out which name and port the catalog is actually reachable at, fix the env file and recreate frontend with the same name, network, 127.0.0.1:8080 publishing and this env file. Don't touch catalog — you may not recreate or restart it.

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 inspect
  • docker logs
  • environment variables

Topic breakdown

Almost every "the service can't see its neighbor" error in Docker is a wrong name, port or network in the configuration. The neighbor's name is the container name (or an alias) in a shared network, and the port is the one the service listens on inside the container, not the one published on the host. A container gets its environment variables once, at creation: editing the env file changes nothing until the container is recreated, and docker restart doesn't reread them. Quick diagnostics: docker logs of the client (where it's knocking), docker inspect of the server (what it's called and what it listens on) and a test request from inside the client.

What's checked

  1. catalog is running, not recreated or restarted
  2. The storefront on 127.0.0.1:8080 gets the catalog's answer
  3. frontend runs with the settings from /root/frontend/frontend.env

What it looks like