Scenario Docker Intermediate

A Running Container Is Unreachable

Separate application binding, published ports, and network connectivity.

1 min read
— Steps
1 Services Used
~30 min Duration
Intermediate Difficulty
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.

  1. Confirm the application started and identify its listening port.
  2. Check that the published container port matches that listening port.
  3. Check which host address and port were published.
  4. For an application inside the container, ensure it listens on an appropriate container interface rather than only its own loopback address.
  5. 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.


Docker Roadmap

Services Used
Docker
Prerequisites
  • Docker fundamentals

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form