Scenario
Docker
Intermediate
A Running Container Is Unreachable
Separate application binding, published ports, and network connectivity.
The Situation
Docker troubleshooting and DevOps interview practice
Scenario
A web container is running, but requests from your browser fail.
Investigation
docker ps
docker port CONTAINER_NAME
docker logs --tail 100 CONTAINER_NAME
docker inspect CONTAINER_NAME
Replace CONTAINER_NAME with the actual name.
- Confirm the application started and identify its listening port.
- Check that the published container port matches that listening port.
- Check which host address and port were published.
- For an application inside the container, ensure it listens on an appropriate container interface rather than only its own loopback address.
- For another container, check the shared network and use the service name and container port.
Controlled Reproduction
docker run -d --name docker-scenario-web -p 127.0.0.1:8094:81 nginx:alpine
The mapping targets port 81, while this nginx image listens on port 80.
Correct and Verify
docker stop docker-scenario-web
docker rm docker-scenario-web
docker run -d --name docker-scenario-web -p 127.0.0.1:8094:80 nginx:alpine
Open http://localhost:8094 and confirm the welcome page.
Cleanup
docker stop docker-scenario-web
docker rm docker-scenario-web
Interview Answer
Running confirms process state. Reachability additionally depends on the application listener, container networking, published port mapping, and the client’s network path.
Add More Questions to This Guide
Know a question that should be here? Share it and help the community!
Open Google Form