Docker Series — Part 7: Custom Networks, IPAM, and Multi-Container Communication

Table of contents

Welcome to Part 7 of the Docker: Basics to Advance series.
Today’s session is all about building real networking control using Docker’s built-in tools — from creating your own networks to running WordPress + MySQL with custom IPs, names, and communication paths.
Docker is Not Just for Containers — It’s Infrastructure Too
When I started using Docker, I thought it was just a tool for running containers. But as I went deeper, I realized — Docker also builds the entire network and storage infrastructure behind the scenes.
From bridges to IPAM (IP Address Management), Docker offers the kind of control you'd expect from full-scale cloud providers.
You can see this using:
docker info
Look at the plugins section — you’ll see Network: bridge, host, macvlan, overlay...
Docker is acting as a virtual router + switch + DHCP + DNS all at once.
What Happens When You Launch a Container?
Docker assigns an IP to your container from a subnet range.
It attaches it to the default bridge network.
It creates a virtual network card for the container (eth0).
The container can ping the internet, but not the other way around (because of NAT).
Understanding Bridge Networking in Docker
Docker creates a default bridge network that acts like a combo device:
It works like a Layer 2 switch (connects systems on the same subnet)
It behaves like a router when containers are on different networks
You can inspect this using:
docker network inspect bridge
Inside the output, you’ll see details like:
Subnet range (
172.17.0.0/16
)IPAM settings
Containers attached to this network
Gateway IP
Creating a Custom Docker Network
Now we go from passive user to network architect
Let’s create our own custom network:
docker network create --driver bridge --subnet 10.1.2.0/24 lwnet
Check it:
docker network ls
You’ll now see lwnet
with your chosen subnet. Docker has now created a new isolated network.
Launching Containers in a Custom Network
docker run -dit --name os4 --network lwnet ubuntu:14.04
Now run:
docker exec -it os4 ifconfig
You'll see:
eth0 → 10.1.2.2
Note:
10.1.2.0
is the network10.1.2.1
is the gateway10.1.2.2
is the container’s IP
You’ve now got control over the IP range, and containers can ping each other by name, thanks to Docker’s IPAM + DNS support.
Deploying WordPress + MySQL in a Custom Docker Network
This is where it gets fun — let’s connect real apps in our network.
Step 1: MySQL Database Container
docker run -dit --name mydb1 --network lwnet \
-e MYSQL_ROOT_PASSWORD=redhat \
-e MYSQL_DATABASE=mydb \
-e MYSQL_USER=jibbran \
-e MYSQL_PASSWORD=redhat \
-v /mydata:/var/lib/mysql \
mysql:latest
Step 2: WordPress Application Container
docker run -dit --name mywp1 -p 8080:80 --network lwnet wordpress:latest
Step 3: Open in Browser
Go to http://<your-server-ip>:8080
During setup, connect WordPress to:
DB Host:
mydb1
DB Name:
mydb
Username:
jibbran
Password:
redhat
WordPress and MySQL are now connected via container name, not IP, inside a custom Docker network!
Key Takeaways
Concept | Summary |
Bridge Network | Default Docker network with NAT & isolation |
IPAM | Manages IP allocation and DNS mapping |
Custom Network | Allows full control over subnet, gateway, container communication |
Container DNS | Containers can ping each other by name |
WordPress + MySQL | Full-stack deployment on Docker with persistent storage and custom networking |
Why This Matters
Using custom Docker networks gives you:
Better security and isolation
Reliable name-based communication
Control over IP schemes (like in cloud infra)
Flexibility for multi-container applications
This is how real production setups are made — controlled, connected, and ready to scale
Have questions about Docker networking, IPAM, or multi-container deployment?
Drop a comment or DM — let’s grow together!
Subscribe to my newsletter
Read articles from Nitin Dhiman directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Nitin Dhiman
Nitin Dhiman
Self-taught DevOps enthusiast on a journey from beginner to pro. Passionate about demystifying complex tools like Docker, AWS, CI/CD & Kubernetes into clear, actionable insights. Fueled by curiosity, driven by hands-on learning, and committed to sharing the journey. Always building, always growing 🚀