October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Kubernetes Day 06: Network Inside Docker, Explained

Networking inside Docker in a Kubernetes lesson means two nested systems: Docker's container networks and port mappings, and Kubernetes Pod IPs and Services. Here is how to tell which one is blocking you.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a Kubernetes lesson talks about “networking inside Docker,” it usually means two separate systems stacked on top of each other. Docker’s networking connects containers to one another and to the host machine. Kubernetes networking gives Pods their own IP addresses and exposes applications through Services. If you cannot reach something from your host, the first job is to work out which of three things you are trying to reach: a Docker container (or a kind node, which is itself a container), a Pod, or a Service. Each has a different access path, and the fix for one rarely applies to the others.

Two layers: Docker networking and Kubernetes networking

Docker networking is about containers on a single Docker host. It decides which containers can talk to each other, whether a container is reachable from the host, and how traffic leaves the machine. Kubernetes networking sits above that. It assigns each Pod a cluster-private IP address and defines how Services route traffic to Pods. The two layers meet when a local Kubernetes cluster is built from Docker containers, as it is with kind, where every Kubernetes node is a Docker container.

As an Amazon Associate I earn from qualifying purchases.

That nesting explains most confusion. A port you publish with Docker is not the same as a port a Kubernetes Service exposes, and a Pod IP is not reachable from the host the same way a published container port is.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Docker bridge networks: how containers reach each other

A bridge network is a software network that connects containers running on one Docker host. Containers attached to the same bridge can communicate with each other. Docker isolates containers on different bridges, and isolates them from external hosts, by default.

There are two practical variants:

  • User-defined bridges provide automatic DNS lookup between attached containers. A container can reach a peer by its container name.
  • The default bridge ordinarily requires containers to address each other by IP address. Name-based access is not the expected pattern there.

If two ordinary containers cannot reach each other, check first that both are attached to the same user-defined bridge and that they use each other’s container name, not an IP you copied from a previous run.

Publishing a port: how the host reaches a container

Containers on a bridge are not reachable from the host by default. You publish a port to create a path from the host into the container. The flag -p 8080:80 means that host port 8080 forwards to container port 80.

The host address you bind to changes who can reach the port:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • No host IP given (for example -p 8080:80): Docker publishes on all host addresses. The port is reachable from other machines that can reach the host.
  • Loopback binding (-p 127.0.0.1:8080:80): the port is bound to the loopback interface, so only processes on the same host can connect.

Docker’s own port publishing documentation warns that a published port is externally reachable by default, so bind to 127.0.0.1 whenever the service does not need to be shared. The same documentation notes a localhost exposure caveat for releases before 28.0.0, involving hosts on the same layer-2 network segment. If you run an older Docker Engine and bind to localhost for sensitive services, check the release notes for your version.

Host networking: removing the network boundary

With the host network driver, the container shares the host’s network stack. It has no separate container IP address, and Docker ignores port-publishing flags such as -p in this mode. A service listening on port 80 inside the container is listening on port 80 on the host. That makes host networking simple, but it removes the isolation that bridge networks provide, and port conflicts with host services become your problem.

kind: Kubernetes nodes running as Docker containers

kind runs each Kubernetes node as a Docker container. That means a kind cluster has two networks to reason about: the Docker network the node containers share, and the Kubernetes network running inside them.

On Linux without Docker Desktop, you can generally reach a kind node’s IP address directly from the host. With Docker Desktop, or when the cluster runs on a remote Docker host, direct access is not reliable and you need port mappings. kind’s extraPortMappings setting forwards a port from a node container to the host. A minimal configuration looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 30080
    hostPort: 8080
    protocol: TCP

The NodePort case has one rule that is easy to miss. The kind node’s containerPort must equal the Kubernetes Service’s nodePort. In the example above, the Service must use nodePort: 30080, and the host then reaches the Service at port 8080:

apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: NodePort
  selector:
    app: web
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30080

If the two numbers differ, the mapping forwards to a port where nothing is listening, and the request fails even though the Service exists.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Docker Desktop: a VM in the middle

On Docker Desktop, containers run inside a Linux virtual machine rather than directly on your host kernel. Docker Desktop’s backend receives connections from the host on published ports and forwards them into that VM. Containers can reach services running on the host through the name host.docker.internal. This extra hop is why a port that works on native Linux may need an explicit mapping on Docker Desktop.

Pods and Services: the Kubernetes layer

Kubernetes gives each Pod its own cluster-private IP address. For ordinary Pod-to-Pod communication, you do not need explicit container links or host-port mappings. Applications are normally reached through a Service, which provides a stable access point in front of a changing set of Pods. Docker’s -p flag never routes to a Pod IP, so if your target is a Pod or Service, Docker port publishing is the wrong tool.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Comparing the network modes

Mode Container IP Container-to-container Host access Port flags
Default bridge Separate container IP Requires IP addresses; name lookup not the expected pattern Through published ports only Honored; -p publishes on all host addresses unless an IP is given
User-defined bridge Separate container IP Same bridge, automatic DNS by container name Through published ports only Honored; same binding rules as the default bridge
Host No separate container IP Shares the host network stack Container listens directly on host ports Ignored by Docker
kind node (Linux) Node container IP reachable directly Kubernetes networking inside the cluster Direct node IP access generally works Not applicable; use extraPortMappings when needed
kind node (Docker Desktop or remote host) Not stated for direct access Kubernetes networking inside the cluster Requires extraPortMappings Mapping defined in kind configuration

A troubleshooting sequence

  1. Identify the destination. Decide whether you are reaching a host service, a Docker container, a kind node, a Pod, or a Service. They sit in different network contexts.
  2. Container to container. Confirm both containers are on the same user-defined bridge, then connect by container name.
  3. Host to container. Run docker ps to confirm the port is published, check the host IP in the mapping (127.0.0.1 or all addresses), and on Docker Desktop confirm the port is reachable through its forwarding path.
  4. Host to kind cluster. Check extraPortMappings in the kind configuration. For NodePort, confirm the node’s containerPort equals the Service’s nodePort.
  5. Pod or Service path. Use Kubernetes networking concepts: test the Service name and port from inside the cluster before adding any Docker-level mapping.

Working through these in order usually isolates the layer that is failing, and it prevents the common mistake of adding a Docker port mapping to a problem that lives entirely inside Kubernetes.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.