Module P-2·25 min read

Bridge vs Host networks, port publishing, internal DNS resolution, and troubleshooting connectivity.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

Introduction

A container running in absolute isolation is useless. It needs to accept incoming HTTP requests, query databases, and talk to other microservices.

However, because Docker relies on Linux Network Namespaces, every container has its own isolated network stack by default. Getting packets in and out of that isolated stack requires understanding Docker's networking models.

In this module, we will explore the three primary network drivers (bridge, host, and none), understand the critical difference between exposing and publishing ports, and see how containers resolve each other via internal DNS.


The Three Primary Network Drivers

When you launch a container, you assign it to a network. If you don't specify one, Docker assigns it to the default bridge network.

1. The none Driver (Total Isolation)

If you start a container with --network none, Docker provisions a Network Namespace but does not configure any interfaces inside it (except the loopback interface, localhost).

The container has no external IP address, cannot reach the internet, and cannot be reached by other containers. It is entirely air-gapped. This is rarely used in typical web applications but is useful for highly secure, localized data-processing containers.

2. The host Driver (No Isolation)

If you start a container with --network host, Docker disables the Network Namespace entirely.

The container shares the exact same network stack as the host operating system. If your Node.js application listens on port 3000 inside the container, it is literally binding to port 3000 on the host machine.

  • Pros: Maximum performance. There is no Network Address Translation (NAT) overhead.
  • Cons: Security and port conflicts. If two containers try to bind to port 3000 using --network host, the second one will crash with an EADDRINUSE error.

[!NOTE] The host networking driver only works on native Linux hosts. It does not work as expected on Docker Desktop for macOS or Windows because the "host" in that context is the hidden Linux VM, not your physical Mac/PC.

3. The bridge Driver (Default & Most Common)

The bridge network is a software-defined switch that sits inside the Linux kernel.

When you use the bridge driver (the default), Docker assigns the container an internal private IP address (e.g., 172.17.0.2). All containers attached to the same bridge network can communicate with each other using these internal IPs.

The bridge is connected to the host's physical network interface via NAT. This allows containers to make outbound requests to the public internet, but prevents the outside world from reaching in—unless you explicitly publish a port.


Exposing vs. Publishing Ports

This is one of the most confusing concepts for Docker beginners.

EXPOSE (Documentation Only)

Sign in to keep reading

The rest of this module is free — sign in with Google to unlock it and track your progress.

Sign in & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.