Skip to main content
Docker automatically creates three networks after installation:
  • bridge
  • host
  • none
Two additional network types are also available:
  • overlay — Connects multiple Docker Daemon hosts (Docker running on different machines).
  • macvlan — Assigns a custom MAC address to a container for direct communication.

Network Types

No network is attached to the container. The container has no access to any external network or other containers and runs in full isolation with no IP configuration.
docker run --network=none ubuntu

Network Operations

List networks

docker network ls

Inspect a network

docker network inspect <network-name>

Remove a network

docker network rm <network-name>
docker network prune  # remove all unused networks

Connect / Disconnect a container

docker network connect <network-name> <container>
docker network disconnect <network-name> <container>

Container Communication

Container to host communication

To communicate with services on the host machine from inside a container, replace localhost or the host IP with host.docker.internal. This domain resolves to the host machine’s IP as seen from inside the container. Example: Change mongodb://localhost:27017/user to mongodb://host.docker.internal:27017/user.

Container to container communication

Build docs developers (and LLMs) love