Containers need networking so they can talk to each other and also reach the outside world (like browsers, APIs, databases, etc.).
Docker handles this by creating virtual networks and connecting containers to them.
None
When a container is started with no network, it has zero connectivity.
It can’t talk to other containers or the internet.
Host
The container uses the host machine’s IP address directly.
No isolation at the network level.
Bridge (default)
This is the most commonly used network.
Docker creates a private network, and each container gets its own internal IP.
Containers on the same bridge network can talk to each other.
To see all Docker networks on the system:
docker network ls
docker network lsTo create a new custom network:
docker network create mynet
docker network create mynetTo inspect a network and see connected containers, IP range, and driver:
docker network inspect mynet
docker network inspect mynetTo remove all unused networks:
docker network prune
docker network prunedocker network create --driver bridge \ --subnet 192.168.50.1/24 \ --ip-range 192.168.50.128/25 \ --gateway 192.168.50.1 mynet
docker network create --driver bridge \
--subnet 192.168.50.1/24 \
--ip-range 192.168.50.128/25 \
--gateway 192.168.50.1 mynetmynetThis gives you full control over container IPs.
docker run -d --network mynet --ip 192.168.50.50 httpd
docker run -d --network mynet --ip 192.168.50.50 httpdIn this command:
mynethttpd) container starts with that IPThis is useful when: