Docker

ram chanduram chandu
4 min read

Blog -1

🐳 Understanding Docker with Monolithic vs Microservices Architecture

In the world of software development, monolithic and microservices are two major architectural styles. As applications grow in complexity, microservices have become the preferred approach — and Docker has emerged as the perfect tool to support them.

In this blog, we’ll explore the difference between monolithic and microservices architecture, and how Docker fits into the picture. We’ll also go through practical Docker commands to get you started.


🧱 Monolithic Architecture

  • In a monolithic architecture, the entire application is built and deployed as a single unit.

  • A single server may run multiple services/modules, such as login, payments, and product catalog — all packed together.

  • The application typically uses one shared database.

  • While it’s simple to start with, it becomes hard to maintain and scale as the application grows.

Example: One big e-commerce app running on one server and one database.


🔗 Microservices Architecture

  • In a microservices architecture, the application is split into independent, loosely coupled services.

  • Each service runs separately, ideally on its own server or container.

  • Each microservice has its own database.

  • This approach improves scalability, maintainability, and deployment speed, but it also increases cost and complexity.

Example: Separate services for authentication, orders, and payments, each deployed and scaled independently.


🐳 Enter Docker: The Microservices Enabler

Managing many microservices is tough — and that’s where Docker comes in.

Docker makes it easy to:

  • Package your code and its dependencies into a Docker image.

  • Run isolated instances called containers.

  • Deploy and scale microservices efficiently and consistently.

🔹 What is a Docker Image?

An image is a lightweight, standalone package that includes:

Code + Dependencies + Runtime + Configuration

🔹 What is a Docker Container?

A container is a running instance of a Docker image. It is isolated, fast, and easy to manage.


⚙️ Docker Architecture Overview

Docker follows a simple architecture:

  1. Client – Where you run Docker commands (CLI).

  2. Host – The server or machine running the Docker Engine.

  3. Registry – A storage for Docker images (e.g., Docker Hub).


🛠️ Installing Docker (on RHEL/CentOS)

# 1. Install Docker
yum install docker -y

# 2. Start Docker service
systemctl start docker

# 3. Check Docker status
systemctl status docker

🚀 Using Docker: Step-by-Step Commands

Let’s go through the key steps to pull and run Docker containers.

1. Pull an Image from Docker Hub

docker pull <image-name>

Example: docker pull nginx

2. Run a Docker Image

docker run <image-name>

3. Run with Options

docker run -itd --name first_container -p 1234:80 <image-name>

Explanation:

  • -itd: Run in interactive + TTY + detached mode.

  • --name: Assigns a name to the container.

  • -p 1234:80: Port mapping

    • 1234 → Host port (used to access the app)

    • 80 → Container port (depends on the image)

Common Port Examples:

  • 80 → Web servers (e.g., Nginx, Apache)

  • 8080 → Jenkins

  • 9000 → SonarQube


4. Check Running Containers

docker ps

5. Stop a Container

docker stop <container-name>

6. Start a Container

docker start <container-name>

⚠️ Important Notes

  • Every new container should have a unique name and a different host port to avoid conflicts.

  • Docker makes it easier to run multiple services (microservices) on the same machine by isolating them using containers.


✅ Conclusion

Docker has become an essential tool for modern development, especially in microservices-based applications. It solves the challenges of environment setup, scalability, and deployment — making your development workflow more efficient.

By learning basic Docker commands and understanding how containers work, you're taking the first big step toward mastering containerized development.


Want to Learn More?

Let me know if you'd like:

  • A Dockerfile example

  • Docker Compose setup for multiple containers

  • Tutorials with Node.js, Python, or Java in Docker

0
Subscribe to my newsletter

Read articles from ram chandu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

ram chandu
ram chandu