DEV Community

Yash Sonawane
Yash Sonawane

Posted on

Docker Series — Episode 14: Docker Networking Deep Dive (Bridge, Host, Overlay)

Welcome back to the Docker series! In the previous episode, we explored Docker Compose advanced scaling and multi-environment setups. Now, let’s dive into one of the most important and often overlooked aspects of Docker: Networking. Understanding how containers talk to each other and the outside world is critical for building real-world applications.


🔹 What You’ll Learn in This Episode

  • Docker networking basics
  • Default Docker networks
  • Bridge, Host, and None networks
  • Overlay networks for multi-host communication
  • Connecting containers across networks
  • Real-world use cases

🔹 Docker Networking Basics

Every container in Docker can communicate with others through networks. By default, Docker assigns containers to certain network drivers.

Run this to see networks:

docker network ls
Enter fullscreen mode Exit fullscreen mode

Example output:

NETWORK ID     NAME      DRIVER    SCOPE
8d6f6a1c3f5e   bridge    bridge    local
c3d9d6b2af6e   host      host      local
9c7fda8e98bb   none      null      local
Enter fullscreen mode Exit fullscreen mode

🔹 Bridge Network (Default)

  • Default network type
  • Used when you run a container without specifying a network
  • Containers get an internal IP and can communicate using container names

Example:

docker run -dit --name container1 busybox sh
Enter fullscreen mode Exit fullscreen mode
docker run -dit --name container2 busybox sh
Enter fullscreen mode Exit fullscreen mode
docker network connect bridge container2
Enter fullscreen mode Exit fullscreen mode

Now, container1 can ping container2 using its name.


🔹 Host Network

  • Removes network isolation between container and host
  • Container shares the host’s networking stack
  • Best for high-performance networking

Example:

docker run -d --network host nginx
Enter fullscreen mode Exit fullscreen mode

Now, Nginx runs directly on host’s IP.

⚠️ Downside: No container isolation.


🔹 None Network

  • Completely disables networking
  • Useful for security-sensitive workloads
docker run -dit --network none busybox sh
Enter fullscreen mode Exit fullscreen mode

This container has no internet access.


🔹 Overlay Network (Multi-Host Communication)

  • Used in Docker Swarm or Kubernetes
  • Allows containers running on different hosts to communicate

Example (Swarm mode):

docker swarm init
docker network create -d overlay my_overlay
Enter fullscreen mode Exit fullscreen mode

🔹 Connecting Containers Across Networks

You can attach containers to multiple networks:

docker network create my_network

docker run -dit --name app1 --network my_network busybox sh
Enter fullscreen mode Exit fullscreen mode

Containers on my_network can communicate securely.


🔹 Real-World Use Cases

  • Bridge: Local development with multiple containers
  • Host: High-performance apps (e.g., monitoring agents)
  • None: Isolated environments
  • Overlay: Multi-host apps in production

🔹 Hands-On Challenge

  1. Create a custom bridge network
  2. Run two containers and make them talk to each other using names
  3. Try host and none networks and compare behaviors

✅ In this episode, you learned how Docker networking works — from bridge to overlay. Mastering this is crucial for scaling apps in production.

Top comments (0)