Sitemap

Docker Networking, SDN & Container Communication — Hands-On Guide

5 min readSep 10, 2026

--

As part of my Docker learning journey, I practiced Docker networking, network drivers, custom bridge networks, container-to-container communication, SDN, Docker Compose, and container lifecycle.

This hands-on practice helped me understand how containers communicate internally and how Docker manages networking behind the scenes.

1. Basic Docker Networking

Docker networking allows containers to communicate with:

  • Other containers
  • The Docker host
  • External networks and the Internet

When Docker is installed, it normally provides some default networks.

To view them:

docker network ls

Typical output:

NETWORK ID     NAME      DRIVER    SCOPE
xxxxxx bridge bridge local
xxxxxx host host local
xxxxxx none null local

These default networks provide different networking options depending on the requirement.

2. Docker Network Drivers

Docker provides different network drivers for different use cases.

   Driver      Purpose
|----------|----------------------------------------------------------------
bridge Default networking option for containers on a single Docker host
host Container shares the host's network namespace
none Container has no network connectivity
overlay Used for communication between containers across multiple
Docker hosts
macvlan Gives containers their own MAC address and makes them appear
as physical devices on the network

For basic container-to-container communication, the bridge driver is commonly used.

3. Creating a Custom Bridge Network

Docker’s default bridge network is useful, but creating a custom bridge network provides better control and built-in DNS-based communication between containers.

I created a custom network using:

docker network create --driver bridge --subnet 10.1.2.0/24 lwnet

Breaking down the command:

  • docker network create → Creates a Docker network
  • --driver bridge → Uses the bridge driver
  • --subnet 10.1.2.0/24 → Defines the network subnet
  • lwnet → Name of the network

The /24 subnet provides 254 usable IPv4 addresses.

To verify the network:

docker network ls

For detailed information:

docker network inspect lwnet

4. Creating Two Containers on lwnet

I created two Ubuntu containers and connected them directly to the custom network:

docker run -dit --name c1 --network lwnet ubuntu
docker run -dit --name c2 --network lwnet ubuntu

The network can be visualized as:

lwnet
10.1.2.0/24
|
┌───────┴───────┐
↓ ↓
c1 c2
10.1.2.2 10.1.2.3

The actual IP addresses can be checked with:

docker network inspect lwnet

5. Testing Container-to-Container Communication

To test communication, I entered the first container:

docker exec -it c1 bash

Ubuntu containers may not have ping installed by default, so I installed it:

apt update
apt install iputils-ping -y

Then I tested connectivity to the second container:

ping 10.1.2.3

Successful ICMP replies confirm that the containers can communicate through the same Docker network.

6. Communication Using Container Names

A useful feature of a user-defined bridge network is Docker’s embedded DNS.

Instead of using the container’s IP address, I can use its name:

ping c2

Similarly, from c2:

ping c1

Docker resolves the container name to its current IP address.

This is useful because container IP addresses can change when containers are recreated, while the service or container name can remain the same.

7. SDN — Software-Defined Networking

SDN stands for Software-Defined Networking.

SDN is an approach where network control is managed through software rather than being tightly coupled to individual network hardware devices.

A simplified SDN architecture looks like:

SDN Controller
|
┌────────────┼────────────┐
↓ ↓ ↓
Network Network Network
Device Device Device

Docker networking uses software-based networking concepts to dynamically create and manage container networks.

On Linux, technologies such as:

  • Network namespaces
  • Virtual Ethernet pairs
  • Linux bridges
  • Routing
  • Firewall rules

help implement container networking.

8. Docker Compose

Modern applications often require multiple containers.

For example:

Frontend
↓
Backend
↓
Database

Managing every container manually can become difficult.

Docker Compose allows multiple services to be defined and managed through a YAML configuration file.

Get Prateek Rajput’s stories in your inbox

Join Medium for free to get updates from this writer.

Example:

services:
web:
image: nginx
ports:
- "8080:80"
  db:
image: postgres
environment:
POSTGRES_PASSWORD: secret

Start the services:

docker compose up -d

Check the services:

docker compose ps

Stop and remove the application:

docker compose down

Compose also creates a network for the application, allowing services to communicate using their service names.

For example:

db:5432

can be used to reach the PostgreSQL service instead of manually finding its container IP.

9. docker info

Another useful Docker command is:

docker info

It displays detailed information about the Docker environment and daemon.

It can show:

  • Number of containers
  • Running and stopped containers
  • Number of images
  • Docker Server version
  • Storage driver
  • Cgroup driver
  • Operating system
  • CPU and memory information
  • Docker root directory
  • Network information
  • Security options

There is an important difference between:

docker version

and:

docker info

docker version focuses on Docker client/server version information, while docker info provides broader information about the Docker environment.

10. Docker Container Lifecycle

A container’s lifecycle is closely tied to its main process.

For example:

docker run ubuntu sleep 30

The container runs while the sleep process is running.

After 30 seconds:

sleep process exits
↓
container stops

The stopped container normally remains available:

docker ps -a

It can then be removed manually:

docker rm <container>

If automatic removal is required, use:

docker run --rm ubuntu sleep 30

After the main process exits, Docker automatically removes the container.

The key concept is:

Main process exits → Container stops
--rm + process exits → Container is removed

11. Useful Docker Networking Commands

Some commands I practiced during this topic are:

# List networks
docker network ls
# Inspect a network
docker network inspect lwnet
# Create a network
docker network create --driver bridge --subnet 10.1.2.0/24 lwnet
# Connect an existing container
docker network connect lwnet c1
# Disconnect a container
docker network disconnect lwnet c1
# Remove a network
docker network rm lwnet
# Inspect container information
docker inspect c1

12. Interview Questions

What is Docker networking?

Docker networking provides communication between containers, the Docker host, and external networks.

What is a bridge network?

A bridge network provides networking between containers on the same Docker host.

Why use a custom bridge network?

It provides isolated networking and Docker’s embedded DNS, allowing containers to communicate using names.

What is SDN?

Software-Defined Networking is a software-based approach to controlling and managing network behavior.

What happens when a container’s main process exits?

The container stops. It is automatically removed only when it was started with the --rm option.

What is Docker Compose?

Docker Compose is used to define and manage multi-container applications using a YAML configuration file.

Conclusion

This hands-on session helped me connect several important Docker concepts:

Docker Networking
↓
Network Drivers
↓
Custom Bridge Network
↓
Container-to-Container Communication
↓
Docker DNS
↓
SDN Concepts
↓
Docker Compose
↓
Container Lifecycle

Understanding Docker networking is an important step toward working with containerized applications, microservices, cloud platforms, and DevOps environments.

Consistent hands-on practice is helping me strengthen my Docker and DevOps fundamentals.

--

--