Y
Yash Sonawane
Guest
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.
Every container in Docker can communicate with others through networks. By default, Docker assigns containers to certain network drivers.
Run this to see networks:
Example output:
Example:
Now,
Example:
Now, Nginx runs directly on hostβs IP.
Downside: No container isolation.
This container has no internet access.
Example (Swarm mode):
You can attach containers to multiple networks:
Containers on
In this episode, you learned how Docker networking works β from bridge to overlay. Mastering this is crucial for scaling apps in production.
Continue reading...
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:
Code:
docker network ls
Example output:
Code:
NETWORK ID NAME DRIVER SCOPE
8d6f6a1c3f5e bridge bridge local
c3d9d6b2af6e host host local
9c7fda8e98bb none null local
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:
Code:
docker run -dit --name container1 busybox sh
Code:
docker run -dit --name container2 busybox sh
Code:
docker network connect bridge container2
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:
Code:
docker run -d --network host nginx
Now, Nginx runs directly on hostβs IP.

None Network
- Completely disables networking
- Useful for security-sensitive workloads
Code:
docker run -dit --network none busybox sh
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):
Code:
docker swarm init
docker network create -d overlay my_overlay
Connecting Containers Across Networks
You can attach containers to multiple networks:
Code:
docker network create my_network
docker run -dit --name app1 --network my_network busybox sh
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
- Create a custom bridge network
- Run two containers and make them talk to each other using names
- Try host and none networks and compare behaviors

Continue reading...