Repair a Broken Nginx Container
A teammate handed you a container that “runs but doesn’t work.” `docker ps` shows it Up, but the browser returns nothing. Find out why and get the site serving.
Learning objectives
- Confirm the container is running
- Identify why the site is unreachable
- Correct the port mapping and/or content mount
- Verify the site responds with HTTP 200
Before you start
Required software: Docker Engine 24+ or Docker Desktop
Prerequisites: Run Your First Container (or equivalent)
- Download the lab archive and unzip it.
- From the lab folder, start the broken environment:
docker compose up -d(or run the providedstart.sh). - Try to load the site at the URL the README says — it will fail; that is expected.
Instructions
1. Observe
List the container and check its ports:
docker ps
docker inspect broken-web --format '{{json .NetworkSettings.Ports}}'2. Look inside
Check what nginx is actually serving:
docker exec broken-web ls -la /usr/share/nginx/html
docker logs broken-web3. Fix it
There are up to three planted problems: a wrong host:container port, a content mount pointing at the wrong path, and/or a missing index file. Correct the compose file and re-apply with docker compose up -d.
4. Validate
Run the validation script and confirm HTTP 200:
bash validation/validate.shHints
💡 It’s Up but nothing loads
A container can be healthy and still unreachable if the published port maps to a port nothing is listening on. Compare the -p mapping to the port nginx listens on (80).
💡 nginx serves a 403 or default page
The document root mount may point at an empty or wrong directory. Check the bind mount target against nginx’s root (/usr/share/nginx/html).
Validate your work
From the lab folder, run:
bash validation/validate.sh The script reads only your local Docker state, never transmits data off your machine, and returns a status code:
0— Lab successfully completed1— Validation failed2— Required dependency missing3— Lab environment not running4— Configuration error5— Validation timed out
Note: validation targets Linux first. On Docker Desktop (macOS/Windows) some host-level checks (e.g. disk usage) may report differently; each script documents its limitations.
Solution
The full solution + troubleshooting explanation is available to signed-in learners. Try to solve it first — that’s where the learning is.
Reset the lab
docker compose downthendocker compose up -drestores the broken starting state from the untouched compose file (keep a copy of the original).
Interview questions
- A container is “Up” but the app is unreachable — what are the first three things you check?
- How do you find which host port maps to a container’s port?
- How would you confirm what files a container is actually serving?
Finished this lab?
Sign in to record your completion and track progress across the path. Completion is recorded server-side.