Published November 14, 2026 · Reviewed November 14, 2026 · Ingenious AI team
The short answer: Carelessly, and by default. When a container is started with a published port — -p 8000:8000 — Docker maps the container's port onto the host's network interfaces, all of them unless you say otherwise, so a server you believe is 'inside a container, therefore contained' is in fact listening on the LAN and reachable through any forward or tunnel like a native service. Docker's networking can also arrange its own forwarding in ways that bypass the host firewall rules a household relies on, which is why the companion census and a host-level port list must be read with containers in mind: the listener belongs to Docker's machinery, and the process column points at the runtime, not the server. The fix is one word long — publish to localhost explicitly, -p 127.0.0.1:8000:8000 — plus the discipline of inventorying every mapping. Check the result from outside with the free check exactly as for a native server.
A container has its own private network space; its services listen there, invisible to the host's network. Publishing (the -p flag, or a ports: entry in Compose) builds a bridge: connections to the host's chosen address and port are forwarded into the container's port. The default host address for that bridge is all interfaces — the 0.0.0.0 habit, wearing a container's clothes.
Two defaults combine. First, the mapping's host side binds all interfaces: the developer wanted the demo reachable from their laptop, and the syntax's shortest form delivers exactly that, to the whole network path that can reach the host. Second, Docker manages its own packet-forwarding rules for published ports, in chains the host firewall's ordinary rule list may not govern the way the household assumes — a service the owner believes is firewalled off can be reachable through its container mapping, because the mapping is not traversing the rules they wrote. Neither behaviour is a bug; both are documented; both are unknown to most households running a tutorial's Compose file, which is the population this guide addresses.
The household translation is blunt: a containerised MCP server with a default mapping is a publicly-shaped server. It deserves the full posture — bind discipline applied at the mapping, a gate if published, a trimmed tool surface — and the container's isolation should be valued for what it genuinely provides (filesystem and process separation from the host) rather than imagined as network privacy it never promised.
The census tools adapt. docker ps lists each container's published mappings in its PORTS column — the household's container-forward inventory, to be read with the same verdict discipline as the listener census: every mapping gets its intended audience stated, and any mapping showing a bare port pair without a host address is wide by default. The host's own listener list (companion, ss) corroborates from the other side: published ports appear there under Docker's proxy or runtime processes, which is why a listener 'owned by Docker' must be chased to its container before it can be verdicted — an unattributed Docker listener is this guide's version of the unexplained row.
Compose files are the durable record: the ports: entries in the household's compose files are the mappings' source of truth, reviewable in an editor in a way runtime state is not. The monthly pass for a container household reads the compose files (short, declarative, diffable) and reconciles them with docker ps — a mapping running that no compose file admits to came from a command line, and command-line containers are the stale-tunnel problem in container form: started for a test, publishing ever since.
The narrow forms are one token away. -p 127.0.0.1:8000:8000 publishes the container's port on the host's loopback only — the gate (proxy, tunnel agent, private route) on the host then decides any wider reach, exactly as for a natively bound server. A LAN-scoped publication names the host's LAN address instead. Services that should not be published at all — the containerised database the MCP server talks to — simply omit the mapping: container-to-container traffic uses Docker's internal networks and needs no host port at all, which makes the database-with-a-published-port one of the container census's most reliable findings, a door built for a caller who never needed it.
Where the server inside the container also has a bind setting, set both layers narrow: the container-internal bind is the second wall if the mapping is ever widened by mistake, and layered narrowness is the theme of this entire series. Then verify from outside: the check should find the endpoint only through its intended gate, and the host census should show the mapping on the address you chose.
Containers have persistence mechanisms of their own — restart policies (unless-stopped, always) and Compose projects long forgotten — that resurrect test containers across reboots with their mappings intact. A household can 'stop' a published test server in the evening and be re-published by morning's power flicker. Retirement, container-style, mirrors the tunnel ritual: stop the container, remove it (and its compose project or run command's record), and confirm after a host reboot that neither the container nor its mapping returns. The stale-tunnel guide's three-part closing — process, persistence, proof — transfers verbatim; only the nouns change.
Inventory the images too, lightly: a pulled image with a documented default credential in its bundled app is the container edition of the Pi's default account. First run of any new image gets the account question asked before its first night, and its published ports get the census treatment before its first hour.
The network page for a container household gains a small table: container, image, published mappings (with the host address each binds), internal-only services, restart policy, and the compose file's location. Six lines per container, and the monthly diff becomes trivial — docker ps against the table, compose files against their last versions. Households that run one MCP container and a database will write this table once and bless it at every audit; households that run a small zoo will bless it sooner.
The container's genuine virtues deserve the closing sentence: reproducibility (the server rebuilt from its file in minutes — a restore story desktops envy) and separation (its filesystem misadventures contained). Governed by the mapping discipline, a containerised home server is among the tidiest shapes a household can run. Ungoverned, it is a tutorial's defaults with a DevOps accent. The difference, as ever in this series, is an inventory and an hour.
Example — fictional, for illustration. The Costa family (whose NAS story is in the NAS guide) runs their MCP server in Docker from a tutorial's Compose file, on the household mini PC. Their first container-aware census reads the compose file with new eyes: three published mappings. The server's own port, published bare — all interfaces. A database port, published bare, though nothing outside the Compose project has ever connected to the database directly. And a debugging port from the tutorial's optional step, published bare, attached to a tool the family does not use. The host firewall, which the family had configured with some pride, never entered the story: the mappings arranged their own passage.
The compose file is edited in one pass — the server republished as 127.0.0.1-only (their gate handles the rest), the database's mapping deleted outright (the server still reaches it over the internal network, unchanged), the debug service removed from the project entirely — and the stack is recreated and verified: outside check grading the gated endpoint as designed, the database simply absent from the host's listener story, a host reboot confirming the stack returns in exactly the edited shape. Before: 3 published mappings, 3 of them all-interfaces, 1 for a service nobody used. After: 1 published mapping, localhost-bound, behind the gate; 0 for the database; table written. Their note: 'The container was never the wall. The mapping was the door, and we had three of them open.'
Companion reading for this topic: How Do You Read ss -tlnp Output to Find Risky Listeners? · What Is the Difference Between Binding to 127.0.0.1 and 0.0.0.0? · You Run Your AI Server on a Mini PC — What Do You Harden First? · What Is the One Authenticated Path Rule for a Home Server?.
Whatever this guide led you to change, prove it the way every guide in this series ends: re-run the free check on the same address and compare the result with the one you started from, work through the local-scan guide for the inside of the house, and see plans if you want the watching done on a schedule. A change you have not re-measured is a hope, not a fix.
It isolates the server's processes and filesystem from the host's — real and valuable separation. Network reachability is a separate axis, governed by the published mappings: a published port deliberately bridges the container to the host's interfaces. Isolation answers 'what can the server touch on this machine'; mappings answer 'who can touch the server'. Confusing the two is the container household's characteristic mistake.
Docker maintains its own forwarding rules for published ports, inserted into the packet path in its own chains; depending on the host firewall's design, those rules can carry traffic past the policies the owner wrote for ordinary host services. The practical upshot matters more than the packet plumbing: do not rely on the host firewall to narrow a container mapping. Narrow the mapping itself — 127.0.0.1 in the publish string — where the control is explicit and auditable.
Include the host address in the mapping: -p 127.0.0.1:8000:8000 on the command line, or '127.0.0.1:8000:8000' in the Compose ports: list. The container's service then answers only on the host's loopback, where your proxy, tunnel agent, or private route decides any wider audience — the same architecture as a natively bound server.
Almost never as a standing mapping. Administer the database from the host (a local client to the container's internal address, or a temporary mapping created for the session and removed in it), and let the standing state be unpublished: the only legitimate standing caller is the application container, which reaches it over Docker's internal network without any host port. A published database port is a door whose legitimate use is measured in minutes per year.
The host's socket table shows published ports under Docker's processes, so the census reveals that something Docker-owned listens — attribution to the specific container comes from docker ps. Read the two together: the companion for the host's whole story, docker ps for the container chapter. An unexplained Docker listener that no container admits to is a finding like any other unexplained row.
HomeShield MCP uses cookies to run the site and, through Google AdSense, to serve ads. Accept or decline non-essential cookies. Details are in the privacy policy.