QA
Beginner LevelDocker & Deployment

What are standard Docker Network Drivers (bridge, host, none, overlay)?

❓ Interview Prompt: Explain Docker network drivers — bridge, host, none, and overlay — with use cases and isolation characteristics.

Docker provides multiple network drivers that determine how containers communicate with each other and the host:

1. Bridge Network (Default):

•
Creates an isolated virtual network bridge (docker0) on the host.
•
Containers on the same bridge can communicate using container names as DNS hostnames.
•
Port publishing (-p 8080:80) exposes specific container ports to the host.
•
Use case: Single-host multi-container apps, development environments.

2. Host Network:

•
Container shares the host's network stack directly — no network namespace isolation.
•
Container binds ports directly on the host NIC — no NAT overhead.
•
Use case: High-performance networking (monitoring agents, network tools). Not available on Docker Desktop (macOS/Windows).

3. None Network:

•
Container has no network interface — completely isolated.
•
Use case: Batch processing jobs that don't need network access; maximum security isolation.

4. Overlay Network:

•
Spans multiple Docker daemon hosts — enables container-to-container communication across machines.
•
Used in Docker Swarm mode for distributed applications.
•
Use case: Multi-host production clusters.

Code Implementation Example

bash
# Create a custom bridge network (better than default bridge)
docker network create --driver bridge myapp-net

# Run containers on the custom network
docker run -d --network myapp-net --name api  my-api-image
docker run -d --network myapp-net --name db   postgres:16-alpine

# Containers can ping each other by NAME (DNS resolution)
docker exec api ping db   # ✅ works via Docker DNS

# Host network — container uses host's network directly
docker run --network host nginx

# None network — no network access
docker run --network none alpine wget google.com  # ❌ fails — isolated

# Overlay network (Docker Swarm)
docker network create --driver overlay --attachable swarm-net
💡Creating and using different Docker network drivers — bridge DNS resolution, host networking, none isolation.
🎯 Interview Key Takeaway

Use custom bridge networks for single-host isolation with DNS; overlay for multi-host Swarm; host for maximum performance; none for air-gapped batch jobs.

#Docker#Networking#Bridge#Overlay#Host Network#Beginner
Back to all Docker & Deployment Questions→

More Docker & Deployment Interview Questions

Beginner LevelDocker & Deployment

How do Docker Multi-Stage Builds minimize image size and improve security?

Beginner LevelDocker & Deployment

What is the difference between a Docker Container and a Virtual Machine (VM)?

Beginner LevelDocker & Deployment

What is the difference between a Docker Image and a Docker Container?