Reaching a Container Through a Published Port

Reaching a Container Through a Published Port

Try Press Step to build the image, then follow the request from host port 4000 before and after the port is published.

Where does the browser request stop?

Port publishing

Track the Dockerfile settings, the running app and the browser route as separate parts of the example.

Recipe and image

Dockerfile

  1. FROM python:slim · Python base
  2. WORKDIR /app · select working directory
  3. ADD . /app · copy project files
  4. RUN · install requirements
  5. EXPOSE 80 · document container port
  6. ENV NAME World · set environment
  7. CMD python app.py · startup command

Image · docker-file

  • Build pending

Browser request

Host browser

  • Browser idle
Request inactive

Host endpoint and firewall

  • Firewall path pending
Route inactive

Container endpoint

  • No running container
  • App not started

Read the recipe

The Dockerfile describes how to build an image and sets the command to run when a container starts.

Observe The route changes from No published mapping to 4000:80 published, and the next frame adds a Web page response lane from the container app to the host browser.
Explain Publishing connects host port 4000 to container port 80. The browser gets a page when the host firewall permits the request and the app is listening on a reachable interface.

Technical boundaries. The trace uses one image and one port pair. It starts a fresh container for the published run. The final comparisons show a missing listener and a blocked request in separate frames, with the publishing command unchanged.

Back to the chapter