Networking Drivers

Difficulty: Advanced

Question

Explain the common Docker networking drivers.

Answer

1. **Bridge (Default)**: Private network on the host. Containers communicate via IP or name if on the same user-defined bridge. 2. **Host**: Container shares the host's network namespace directly (no isolation, best performance). 3. **Overlay**: Connects multiple Docker daemons together (used in Swarm). 4. **None**: Disables all networking for the container.

Code examples

Creating a network

docker network create my-net
docker run -d --name db --network my-net redis
docker run -it --network my-net alpine ping db

Standard bridge networking allows 'alpine' to find 'db' by its container name.

Key points

Concepts covered

Bridge, Host, Overlay, None