What are the different Docker networking modes and when would you use each?

Medium Topic: Docker June 17, 2026

Docker provides several networking modes (drivers) that control how containers communicate with each other and the outside world.

Network Modes Overview

1. Bridge (Default)

Containers on the same bridge network can communicate via IP or container name. Containers are isolated from the host network.

# Default bridge (docker0)
docker run -d --name web nginx

# Custom bridge network (recommended)
docker network create mynet
docker run -d --name web --network mynet nginx
docker run -d --name app --network mynet myapp
# 'app' can reach 'web' by hostname 'web'

Use when: Most container-to-container communication within a single host.

2. Host

Container shares the host’s network namespace. No network isolation, maximum performance.

docker run -d --network host nginx
# Now nginx listens on host's port 80 directly

Use when: High-performance networking, network monitoring tools, when you need host-level network access. Not available on Mac/Windows Docker Desktop.

3. None

Container has no network interface (only loopback). Complete network isolation.

docker run -d --network none myapp

Use when: Batch processing jobs that don’t need network access, maximum security isolation.

4. Overlay

Enables communication between containers on different Docker hosts. Used with Docker Swarm.

docker network create --driver overlay myoverlay

Use when: Multi-host deployments, Docker Swarm services that span multiple nodes.

5. Macvlan

Assigns a MAC address to a container, making it appear as a physical device on the network.

docker network create -d macvlan \
  --subnet=192.168.1.0/24 \
  --gateway=192.168.1.1 \
  -o parent=eth0 mymacvlan

Use when: Legacy applications that expect to be directly connected to the physical network, network monitoring.

6. IPvlan

Similar to Macvlan but containers share the host’s MAC address.

Use when: When MAC address proliferation is a concern on the network switch.

Comparison

ModeIsolationPerformanceUse Case
BridgeMediumGoodDefault, single host
HostNoneBestHigh performance
NoneCompleteN/ABatch jobs
OverlayMediumMediumMulti-host/Swarm
MacvlanHighHighLegacy/physical apps

Best Practice

Always use custom bridge networks over the default bridge. Custom networks provide:

  • Automatic DNS resolution by container name
  • Better isolation
  • Dynamic connect/disconnect of containers
← Previous What are Docker multi-stage builds and how do...

Practice Similar Questions

Back to Docker Topics