Skip to content
Skip to this exploration
All explorations

Practical self-hosting · beginner

07 · Localhost belongs to somebody

Reason about container service names and connection boundaries.

10 min 5 sectionsv1

What you can take away

  • Trace a request through host and container network contexts.
  • Draw three paths: browser to web, web to database, and operator terminal to database

Your trail through this idea

Checking saved progress…

A browser reaches an app, but the app cannot reach its database. The address looks correct because it worked from a terminal. The missing question is: from whose network context?

Prerequisite: complete the preceding lesson or bring its worksheet.

Mark sections complete when you choose. Reading alone does not mark them.

Understand the system

With ordinary Compose networking, services on the same network can discover one another by service name. Published ports are the host-facing entry points; the service-to-service connection normally uses the container port. localhost refers to the current network namespace, so it need not identify the host or another container. Docker explains these boundaries and service discovery.

Draw a connection as source process → name resolution → destination process → destination port. Authentication comes after reaching the intended service. A connection refusal, a DNS failure, and a rejected password point to different stages. Broadly opening ports does not diagnose which stage failed.

Checking saved progress…

Work through the case

Original example: web and database share a practice network. The web application is configured to connect to localhost. In a normal isolated container network, that points back to the web container. Replacing it with the configured database service name addresses discovery, but only if both services share the right network and the database listens on the expected port.

Checking saved progress…

Make something useful

Try this

Original exercise

Draw three paths: browser to web, web to database, and operator terminal to database. Label which paths require published ports. On paper, remove the database’s host publication and predict which paths still work. Use this as a design review only; do not change firewall rules or a live network. If inspecting a practice Compose file, keep network names and addresses out of public notes.

Checking saved progress…

Check your reasoning

A quick check · for your own learning

In a normally isolated container, what does localhost identify?

Choose one answer

A self-study prompt. You can retry; this is not an exam.

Checking saved progress…

Keep the result and follow the sources

The result should separate reachability from authorization. A service that is reachable internally need not be reachable from the internet. Next, extend the request path through public naming and certificate validation.

Sources and scope

  • Primary documentation or archival source, reviewed 14 November 2026. Additional direct links appear beside the claims they support.
  • Editorial basis: Ian's historical self-hosting questions and current repository inspection informed the case selection. Historical requests do not establish current deployment. Private chat records, credentials and host details are excluded.
  • Examples and exercises are original educational synthesis. External sources support the stated technical or historical context, not every hypothetical scenario.
Checking saved progress…

These checks are for reflection and practice. Your answers and reflection notes are not sent anywhere.

Back to all explorations