Connect the Microservices
Fix name resolution between containers with a user-defined network.
A advanced Docker challenge worth 20 points. Solve it hands-on in a real Docker environment in your browser - no local setup, no fake shells.
The Challenge
Scenario: The web nginx proxy forwards to http://api/ — and keeps crashing with "host not found in upstream". Both containers sit on Docker's default bridge, where container names don't resolve.
Tasks:
- Confirm the failure:
docker ps -a,docker logs web - Create a user-defined bridge network shopnet
- Run api on it:
docker run -d --name api --network shopnet busybox sh -c 'mkdir -p /www && echo "{\"service\":\"orders\",\"status\":\"ok\",\"orders\":42}" > /www/index.html && httpd -f -p 80 -h /www' - Run web on it too (image
web:v1, port 8080 → 80) - Browser panel: JSON from the api, proxied through nginx
Commands to learn: docker network create, docker run --network, embedded DNS
Run check when done.