Sitemap

🐳 Day 13: Docker Networking Basics (Containers Talking Like Microservices)

2 min readFeb 2, 2026

--

One of the most common beginner mistakes:

“My app can’t connect to the database container.”

Let’s understand why and how Docker networking actually works.

🧠 Why localhost Fails Between Containers

Each container:

  • Has its own network stack
  • Own IP address
  • Own loopback interface

So:

localhost inside container ≠ host ≠ other container

📡 Default Bridge Network

When you run:

docker run nginx

Docker connects the container to the default bridge network.

Problems:
❌ Containers must use IPs
❌ IPs change on restart
❌ Not production-friendly

✅ User-Defined Bridge Network (BEST PRACTICE)

docker network create app-net
docker run -d --name web --network app-net nginx
docker run -d --name db --network app-net mysql

Now:

web → db (by name)

Docker provides built-in DNS.

🌐 Common Docker Network Types

1️⃣ bridge

  • Default
  • Local development
  • Most common

2️⃣ host

  • Container uses host network
  • No isolation
  • Used for performance testing

3️⃣ none

  • No networking
  • Full isolation
  • Security testing

4️⃣ overlay

  • Multi-host networking
  • Docker Swarm / legacy

🚨 Real Production Incident

A team hardcoded container IPs.

Get Tinesh Krishna’s stories in your inbox

Join Medium for free to get updates from this writer.

Result:

  • Container restarted
  • IP changed
  • App crashed

Fix:
👉 Used user-defined bridge + container names
👉 Issue resolved permanently

🎯 Beginner Takeaway

Remember this rule:

Containers communicate via networks, not localhost.

If multiple containers exist → create a network.

🔜 What’s Next?

In Day 14, we’ll cover:
🐳 Docker Compose

  • Running multi-container apps easily
  • Real-world examples
  • Interview questions

📌 Follow the Series

This #25DaysOfDocker series focuses on:

  • Real production problems
  • Beginner-friendly explanations
  • Interview-relevant topics
  • Practical DevOps mindset

Day 13 done — you just unlocked microservice networking basics 🚀

--

--

Tinesh Krishna
Tinesh Krishna

Written by Tinesh Krishna

DevOps Engineer sharing insights on automation, CI/CD pipelines, Docker, Kubernetes, and cloud-native technologies—based on hands-on experience.