Docs / Containers & Docker / Docker Networking: Connecting Containers

Docker Networking: Connecting Containers

By Admin · Feb 25, 2026 · Updated Apr 25, 2026 · 248 views · 1 min read

Docker provides several network modes for container communication.

Default Bridge Network

Containers on the default bridge network can communicate via IP but not by name.

Custom Bridge Network (Recommended)

# Create network\ndocker network create mynetwork\n\n# Run containers on the network\ndocker run -d --name web --network mynetwork nginx\ndocker run -d --name db --network mynetwork mysql:8\n\n# Containers can reach each other by name\ndocker exec web ping db

Docker Compose

Docker Compose automatically creates a network for all services in the compose file. Services can reach each other by service name.

Host Network

docker run --network host myapp

Container shares the host's network directly. No port mapping needed.

Was this article helpful?