Exploring Docker Networking and Understanding Cloud Networking
Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).
Introduction
Containers are heavily used in modern cloud environments. Cloud services such as Kubernetes, Amazon ECS, Azure Kubernetes Service (AKS), and Google Kubernetes Engine (GKE) rely on container networking.
In this tutorial, you will create multiple Docker containers and explore how they communicate using Docker networks.
Lab Environment
Host:
Windows 11
Docker Desktop
Containers:
PHP Container
MySQL Container
Part 1: Default Bridge Network
Run:
docker run -d --name web nginx
Check:
docker network ls
Expected:
bridge
host
none
Inspect:
docker network inspect bridge
Observation
Container automatically joins bridge network.
Cloud Networking Analogy
Equivalent to:
Virtual Network
|
Multiple VMs
or
AWS VPC
Part 2: Create Custom Network
Create:
docker network create appnet
Verify:
docker network ls
Cloud Networking Analogy
Equivalent to:
AWS VPC
Azure VNet
Google VPC
A custom Docker network acts like a cloud virtual network.
Part 3: Connect Containers
Run MySQL:
docker run -d ^
--name db ^
--network appnet ^
mysql:8
Run PHP:
docker run -d ^
--name web ^
--network appnet ^
php:8.3-apache
Inspect:
docker network inspect appnet
Observation
Containers discover each other automatically.
PHP can reach:
db
without knowing the IP address.
Cloud Networking Analogy
Equivalent to:
Private DNS
Service Discovery
Internal Load Balancer
used in Kubernetes and cloud platforms.
Part 4: Port Mapping
Run:
docker run -d ^
-p 8080:80 ^
nginx
Access:
http://localhost:8080
Observation
External users access container through mapped port.
Cloud Networking Analogy
Equivalent to:
Public IP
Load Balancer
NAT Rule
Concept:
Internet
|
Port Mapping
|
Container
Part 5: Container Isolation
Create:
docker network create backend
Run database:
docker run -d ^
--name db ^
--network backend ^
mysql:8
Do not publish ports.
Observation
Database is hidden.
Only backend applications can access it.
Cloud Networking Analogy
Equivalent to:
Private Database Subnet
used for:
Amazon RDS
Azure SQL
Cloud SQL
Part 6: Docker Compose Architecture
Example:
services:
web:
image: php:8.3-apache
db:
image: mysql:8
Docker Compose automatically creates:
Application Network
Cloud Networking Analogy
Equivalent to:
Infrastructure as Code
such as:
AWS CloudFormation
Azure ARM Templates
Terraform
Part 7: Mapping Docker Networking to Cloud Networking
| Docker | Cloud Equivalent |
|---|---|
| Bridge Network | VPC / VNet |
| Container | VM / Pod |
| Custom Network | Private Network |
| Port Mapping | Public IP / NAT |
| Container DNS | Service Discovery |
| Docker Compose | Infrastructure as Code |
| Overlay Network | SDN Overlay |
| Container Cluster | Kubernetes Cluster |
What Students Learned
After completing this tutorial students understand:
Container networking
Service discovery
Port publishing
Network isolation
Private and public services
Cloud-native networking concepts
These concepts directly prepare students for Kubernetes, ECS, AKS, GKE, VPCs, VNets, and cloud load balancing.