- Регистрация
- 9 Май 2015
- Сообщения
- 1,570
- Баллы
- 155
Hello dev.to community! ?
terday, I explored Docker Basics — the foundation of containerization. Today, I’m diving into Networking & Volumes in Docker — two essential concepts that bring containers closer to real-world use cases. ?? Why Networking & Volumes Matter
Networking → lets containers communicate with each other and the outside world.
Volumes → ensure data persists even if containers are removed.
In DevOps, both are crucial for building reliable, production-ready systems.
? Core Concepts I’m Learning
? Docker Networking
Bridge network (default): containers get private IPs and can talk to each other.
Host network: container shares host’s network.
Overlay network: connects containers across multiple hosts (used in Swarm/K8s).
? Example:
docker network create mynet
docker run -d --name web --network mynet nginx
docker run -it --network mynet alpine ping web
? Docker Volumes
Volumes store data outside container lifecycle.
Great for databases, logs, and config files.
Types: named volumes, host mounts, anonymous volumes.
? Example:
docker volume create mydata
docker run -d -v mydata:/var/lib/mysql mysql
?️ Mini Use Cases in DevOps
Run a database container with volumes to persist data.
Connect backend & frontend containers via networks.
Share config files securely across multiple services.
Use named volumes instead of host paths for portability.
Inspect networks with:
docker network ls
docker network inspect mynet
Clean up unused volumes & networks:
docker volume prune
docker network prune
? Hands-on Mini-Lab (Try this!)
docker network create devnet
docker run -d --name mynginx --network devnet nginx
docker run -d --name myredis --network devnet redis
docker exec -it mynginx ping myredis
? Containers are now talking to each other inside devnet! ?
? Key Takeaway
Networking connects containers like a mini-internet, while volumes ensure data survives beyond container restarts. Together, they make Docker production-grade.
? Tomorrow (Day 9)
I’ll dive into Dockerfiles & Image Building — automating app packaging for CI/CD pipelines.
? #Docker #Containers #DevOps #CICD #DevOpsJourney #CloudNative #SRE #Automation #OpenSource
Источник: