Networking
Docker Network Types
Bridge Network (Default)
Used for communication between containers on the same host.
Created automatically when running containers.
Manually create: docker network create my_bridge_network
Docker Compose:
#yaml
networks:
my_bridge_network:
driver: bridgeHost Network
Containers share the host’s network namespace (no isolation).
Manually create: docker network create -d host my_host_network
Docker Compose:
# yaml
networks:
my_host_network:
driver: hostOverlay Network
Used in Swarm mode for multi-host communication.
Manually create: docker network create -d overlay my_overlay_network
Docker Compose:
Macvlan Network
Assigns containers unique IPs on the local network.
Manually create: docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=eth0 my_macvlan_network
Docker Compose:
None Network
Completely isolates the container (no networking).
Manually create: docker network create -d none my_none_network
Docker Compose:
Specify static ip address
Commands
docker network ls
docker network inspect $name
docker network connect $network $container: connect $container to $network
docker network create -d macvlan -o parent=enp86s0.4 vlan4_net: create network
docker network create -d macvlan --subnet=192.168.4.0/24 --gateway=192.168.4.1 -o parent=enp86s0.4 vlan4_net
Reference
Last updated