Introduction
Docker has revolutionized the way software is developed and deployed. A vital part of this ecosystem is Docker Networking, which governs how containers communicate with each other and with external systems.

This article will explore Docker Networking, its various types, and how to implement them.
Docker Networking
Docker Networking facilitates communication between Docker containers and other network endpoints. It abstracts complex network topology and makes it easy to connect containers running on the same host or different hosts.
Networking Drivers in Docker
Docker provides several built-in networking drivers to accommodate various use cases. The three primary networking drivers are:
-
Bridge Network: Used when containers need to communicate on the same Docker host.
-
Overlay Network: Useful for connecting multiple Docker daemons, typically in a Swarm cluster.
- Host Network: Bypasses the Docker’s network stack and attaches to the host’s network directly.
Bridge Networking
Bridge networking is the default network type for containers. When Docker is installed, a new virtual bridge network is automatically created, and containers connect to it.
Creating a Bridge Network
docker network create --driver bridge my_custom_network
Connecting Containers to Bridge Network
docker run -d --name my_container --network my_custom_network my_image
Overlay Networking
Overlay networks enable swarm services to communicate with each other. It requires a key-value store like Consul or etcd and works across multiple hosts.
Creating an Overlay Network
docker network create -d overlay my_overlay
Host Networking
Host networking is useful when a container should not be isolated from the Docker host's network stack.
Running Container with Host Networking
docker run --network host my_image
Docker Network Commands
Here are some commonly used commands:
-
Inspect Network: docker network inspect NETWORK_NAME
-
List Networks: docker network ls
- Remove Network: docker network rm NETWORK_NAME
Docker Compose and Networking
Docker Compose allows you to define multi-container applications. In the docker-compose.yml file, you can define networks as well.
version: '3'
services:
web:
image: nginx
networks:
- my_network
networks:
my_network:
driver: bridge
Also see, Install Homebrew