Types of Docker Network Drivers
1. Bridge Driver
docker network create my-network
# By default this creates a bridge type network
The bridge network is the default network driver. If you don't specify a driver, this is the type of network being created.
We already saw this — when we created a custom network without specifying a driver, it defaulted to bridge type.
When is Bridge Used?
Bridge networks are commonly used when our application runs in a container that needs to communicate with other containers on the same host.
Types of Bridge Networks
1. Default Bridge Network
- Automatically created by Docker
- Used when no custom network is specified
- Containers need extra configuration to communicate
2. Custom Bridge Network
- Created manually by us
- Example:
docker network create my-network
Key Difference
In custom bridge networks:
- Containers can interact directly
- No need for IP addresses
- No need for manual port-based communication inside network
- Containers can use container names as hostnames
Real Example
This is how MongoDB and Mongo Express worked together:
- Both containers were added to the same custom bridge network
- Mongo Express connected to Mongo using container name (
mongo)
- No external IP required
2. Host Driver
In the host network, the container uses the same network as the host machine.
Key Behavior
- Container does NOT get its own IP address
- Shares host machine’s network stack directly
- No network isolation
When is Host Used?
Use host networking when:
- We want maximum performance
- We want direct access to host network
- We don’t need isolation between host and container
Example
Container → Host Network → External Internet
3. None Driver
The none network provides complete isolation.
Key Behavior
- No network access at all
- No internet
- No container-to-container communication
- Fully isolated environment
Example
docker run --network none mongo
When is None Used?
Use it when:
- Security is critical
- No external communication is required
- Testing isolated environments
Creating a Custom Network
docker network create my-network
Verify Network Creation
Running Container in Custom Network
docker run -d \
--name mongo \
--network my-network \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=qwerty \
mongo
Key Idea
- Container is now attached to
my-network
- It can communicate with other containers in the same network
- It uses container names instead of IPs
Deleting a Network
docker network rm mongo-network
Verify Deletion
Now only default networks remain:
Summary of Network Drivers
| Driver | Description | Use Case |
|---|
| bridge | Default isolated network | Multi-container apps |
| host | Shares host network | High-performance apps |
| none | No networking | Fully isolated containers |
Key Takeaway
Docker networking determines how containers communicate:
- Bridge → Safe and most commonly used
- Host → Fast but no isolation
- None → Fully isolated environment
Custom bridge networks are the most important for real-world applications, especially microservices.