Part 5 – Docker Networking

# Packages required
apt-get update && apt-get install net-tools bridge-utils iputils-ping iproute2 -y  

# Show nat rules
iptables -t nat -L -n

# Show bridge NetworkSettings
brctl show

# Show all network in docker 
sudo docker network ls

# remove unused Networks
docker network prune

# Create a new custom bridge network 
docker network create –driver bridge vlan20
docker network create –driver bridge vlan2000

#  Create a container in network host /bridge/none
sudo docker run -dt –name web99 –network host busybox:latest
docker run -dt –name web10 –network vlan20 imagename
docker run -dt –name web10 –network none imagename

# Show containers in a network
docker network inspect bridge
docker network inspect host

# Get IP address for all containers
docker inspect –format='{{.Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ $(docker ps -q)

# Get IP address for a specific container
docker inspect <container id> | grep “IPAddress”

(Visited 56 times, 1 visits today)

By C A Thomas

Chinchu A. Thomas is an Infrastructure Analyst specializing in Microsoft Azure, the Microsoft 365 suite, AWS, and Windows infrastructure management products.

Leave a Reply