Loading

Quipoin Menu

Learn • Practice • Grow

docker / Docker Networking
tutorial

Docker Networking

When you run containers, they often need to communicate with each other or with the outside world. Docker provides several network drivers to control how containers connect.

Why Networking Matters

By default, a container runs in its own network namespace. It can talk to the outside world through the host, but other containers are isolated unless you connect them via a network. Docker networks give you:
  • Isolation: separate networks for different applications.
  • Service discovery: containers can find each other by name.
  • Custom IP ranges and routing.

Default Networks

When Docker is installed, it creates three networks automatically. View them with:
docker network ls
  • bridge: The default network. Containers on this network can talk to each other via IP, but not by name.
  • host: Removes network isolation, container uses the host's network directly.
  • none: No networking.

User‑Defined Networks

You can create your own networks, which provide automatic DNS resolution (containers can reach each other by container name). Create a network:
docker network create my-network
Then run containers attached to it:
docker run -d --name app1 --network my-network nginx
docker run -it --name app2 --network my-network alpine ping app1
You'll see that app2 can ping app1 by name.

Inspecting Networks

See details of a network:
docker network inspect my-network
This shows connected containers and IP addresses.

Connecting and Disconnecting

You can attach a running container to a network:
docker network connect my-network app1
Disconnect:
docker network disconnect my-network app1


Two Minute Drill
  • List networks: docker network ls.
  • Create a user‑defined network: docker network create my-net.
  • Containers on the same user‑defined network can communicate by name.
  • Inspect networks with docker network inspect.
  • Connect/Disconnect containers dynamically with docker network connect/disconnect.

Need more clarification?

Drop us an email at career@quipoinfotech.com