- Networking background
- Creating Docker container networks
- Network-less and host-mode containers
- Publishing services on the ingress network
-
5.1 Networking background( for beginners)
5.1.1 Basics: Protocols, interfaces, and ports
5.1.2 Bigger picture: Networks, NAT, and port forwarding
5.2 Docker container networking
docker network ls
5.2.1 Creating a user-defined bridge network
Build a new network with a single command:
docker network create \
--driver bridge \
--label project=dockerinaction \
--label chapter=5 \
--attachable \
--scope local \
--subnet 10.0.42.0/24 \
--ip-range 10.0.42.128/25 \
user-network
5.2.2 Exploring a bridge network
start exploring your new bridge network by creating a new container attached to that network:
docker run -it \
--network user-network \
--name network-explorer \
alpine:3.8 \
sh
docker network create \
--driver bridge \
--label project=dockerinaction \
--label chapter=5 \
--attachable \
--scope local \
--subnet 10.0.43.0/24 \
--ip-range 10.0.43.128/25 \
user-network2
docker network connect \
user-network2 \
network-explorer
docker attach network-explorer
5.3 Special container networks: host and null
docker run --rm \
--network host \
alpine:3.8 ip -o addr
docker run --rm \
--network none \
alpine:3.8 ip -o addr
5.4 Handling inbound traffic with NodePort publishing
docker run --rm \
-p 8080 \
alpine:3.8 echo "forward ephemeral TCP -> container TCP 8080"
docker run --rm \
-p 8088:8080/udp \
alpine:3.8 echo "host UDP 8088 -> container UDP 8080"
docker run --rm \
-p 127.0.0.1:8080:8080/tcp \
-p 127.0.0.1:3000:3000/tcp \
alpine:3.8 echo "forward multiple TCP ports from localhost"
5.5 Container networking caveats and customizations
5.5.1 No firewalls or network policies
5.5.2 Custom DNS configuration
docker run --rm \
--hostname barker \
alpine:3.8 \
nslookup barker
5.5.3 Externalizing network management