Docker Networking

Level : Intermediate
Mentor: Shailendra Chauhan
Duration : 00:03:00

Docker Networking

A network is a collection of two or more devices that can connect, whether physically or virtually. The Docker network is a virtual network developed by Docker to facilitate communication between Docker containers. 

Different types of Docker Networking

Following are the types of Docker Networking:

  • Single Host
  • Multi-Host

Docker Single Host Networking

Docker Single Host Networking provides communication between containers on the same host via a virtual network bridge, allowing for smooth interaction while isolating them from external networks.

Docker Multi-Host Networking​

Docker Multi-Host Networking enables containers running on various hosts to communicate with one another via overlay networks, offering seamless connectivity across distributed settings while abstracting underlying network difficulties.


Network Drivers

Docker network drivers define networking behavior, allowing containers to communicate with one another. 

Types of Network Drivers

  • Bridge
  • Host
  • Overlay
  • Ipvlan
  • Macvlan

Docker Network Working

  • Docker uses your host's network stack, altering iptables rules for traffic routing to containers to ensure isolation.
  • On Linux, packet filtering is controlled by iptables, and Docker automatically manages container traffic rules.
  • Each Docker container has its network namespace for isolation, with virtual network interfaces allowing communication across the host's network.

IP Address

An IP address consists of four numbers separated by periods. In general, it looks like 147.181.183.86. ​ The numbers will range from 0 to 255. So, 255 is the greatest number in an IP address, and 0 is the smallest value.

Subnet

Similar to an IP address, and used to group IP addresses. The common subnet mask is 255.255.255.0. ​These numbers range from zero to 255. 

Bridge

The default bridge driver in Docker creates a private network for a single host, with each container having its network namespace. It allows containers to communicate within the bridge but limits communication between containers on different bridges, while also permitting external access via port mapping.

Host

The Host Network Driver allows containers to use the host's network stack directly, removing network isolation between the host and the containers. It is useful for deploying one or more containers on a single host while ensuring that each container uses a unique port.

Overlay

The Overlay driver enables communication between Docker daemons in a swarm, resulting in simple and secure multi-host networking. It facilitates seamless communication between all containers in the overlay network.

Ipvlan

IPvlan in Docker allows each container to have its own unique MAC address and IP address on the same subnet, allowing network isolation while directly accessing the host's physical network interface.

Macvlan

Macvlan in Docker assigns a unique MAC address to each container on the host's physical network, allowing them to communicate with external networks as if they were physical devices. This provides network isolation and boosts performance for containerized apps.

Docker Network Commands

  • docker network ls
  • docker network create
  • docker network inspect
  • docker run --network
  • docker network connect
  • docker network disconnect
  • docker network rm
  • docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}"
Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this