DAY-12 challenge: Deploying a Multi-Container Application with Docker Networks
Shina Gupta
DevOps Engineer || AzureDevops CICD pipelines implemented || Kubernetes || Docker || Terraform || Ansible || Linux Shell Scripting || Ex-HCLite || Ex-TCS || Team Player || Knowledge Seeker ||
Another interesting DevOps SRE Daily Challenge! I must say I am starting to enjoy these mini well to do tasks. Docker networking enables seamless interaction between containers, allowing applications to function as cohesive units.
The task: setting up and running the Yelb application using a user-defined Docker bridge network.
?? Step 1: Create a Docker Network ??
?? Step 2: Deploy Redis Server ???
Redis acts as a caching layer for storing page views. We'll run Redis within our yelb-network and expose it on port 6379
?? Step 3: Run PostgreSQL Database ???
We need a database to store persistent vote data. We'll deploy PostgreSQL using the mreferre/yelb-db image.
?? Step 4: Start the Yelb App Server ??
The application server processes user requests and connects to both Redis and PostgreSQL.
?? Step 5: Launch the Yelb UI ??
The front-end interface connects to the Yelb app server and presents the UI to users.
?? Step 6: Test the Application ??
Open your browser and navigate to the port number on the local host.
All the commands are readily available in the repository: https://github.com/shinagupta/SRE-CHALLENGES.git
?? What if we hadn’t used a user-defined network?
1?? Harder to Find Each Other ??
Right now, our containers can call each other by name (e.g., yelb-appserver can talk to yelb-db). Without a user-defined network, they wouldn’t recognize names and would need to use changing IP addresses—like trying to call a friend whose phone number keeps changing! ???
2?? More Manual Work ?
With a user-defined network, containers automatically know where to send data. Without it, we'd need to manually open ports and configure each connection—like giving everyone in an office their own walkie-talkie and hoping they tune into the right channel. ??
3?? Security Risks ??
A custom network keeps our services grouped together, like a private chat room. Without it, they’d all be in a giant public forum where other containers could listen in or interfere. ????
4?? Messy Scaling ??
If we wanted to add more services later, a user-defined network makes it easy. Without it, we’d have to keep track of more ports and IP addresses, making things complicated—like adding more people to a group call but having to dial their number each time. ????