Docker

DevOps Engineer | Sharing insights on Kubernetes, Docker, CI/CD & Cloud | Writing to simplify complex tech
Docker we call as containerization
๐น What is Docker?
Docker is an open-source platform that helps you build, package, and run applications in containers.
A container is a lightweight, portable unit that bundles:
Application code
Runtime
Libraries
Dependencies
This ensures your app runs the same everywhere (developer laptop, test, production, cloud).
๐น Why Docker?
Without Docker, apps often face the classic problem:
"It works on my machine but not in production."
Docker solves this by putting everything the app needs into a container that can run anywhere.
๐น Key Concepts
Image โ A snapshot/blueprint of your app (e.g., Python + Flask app).
Container โ A running instance of an image.
Dockerfile โ A script to build an image (instructions on how to package the app).
Docker Hub โ Public registry to share and download Docker images.
๐น Advantages
โ
Portability โ Runs the same on Windows, Linux, Mac, or cloud.
โ
Lightweight โ Uses fewer resources than Virtual Machines (VMs).
โ
Faster deployment โ Containers start in seconds.
โ
Isolation โ Each container has its own environment (no conflicts).
โ
Scalability โ Works well with Kubernetes and microservices.
๐น Docker vs Virtual Machine
VM โ Heavy, full OS per instance.
Docker Container โ Lightweight, shares host OS kernel.
To develop application we have two types of process:
Monolithic :
A monolithic architecture (or simply monolithic) is a traditional software design style where the entire application is built as a single, unified unit.
Hereโs a breakdown:
๐น What it means
All features (UI, business logic, database access, etc.) are tightly coupled and packaged together in one codebase.
Typically deployed as a single executable or a single service.
๐น Characteristics
Single codebase โ All modules (authentication, payments, product catalog, etc.) are bundled together.
Single deployment โ Even if you change a small feature, you must redeploy the whole application.
Tightly coupled โ Components are highly dependent on each other.
Shared database โ Usually one database is used for the entire app.
๐น Advantages
Easy to develop initially (simple structure).
Straightforward testing (everything in one place).
Easier debugging (logs are centralized).
Good performance for small-scale apps (no network calls between services).
๐น Disadvantages
Scalability issues โ Can only scale the whole app, not specific parts.
Slower development over time (large codebase becomes hard to manage).
Limited flexibility โ Canโt easily adopt new tech for just one part of the system.
Risky deployment โ A bug in one part may bring down the entire system.

Microservices:
๐น What is Microservices Architecture?
A microservices architecture is a way of designing software applications as a collection of small, independent services.
Each service focuses on doing one specific function well and communicates with other services using lightweight protocols (like REST APIs, gRPC, or messaging queues).
๐น Characteristics
Independently deployable โ Each service can be built, tested, and deployed without affecting others.
Loosely coupled โ Services communicate but donโt depend tightly on each other.
Polyglot flexibility โ Different services can use different programming languages, databases, or frameworks.
Decentralized data โ Each microservice often has its own database (no single shared DB).
๐น Advantages
โ
Scalability โ You can scale only the services that need more resources (e.g., scaling "payment" service, not the whole app).
โ
Faster development โ Small, focused teams can work on different services in parallel.
โ
Resilience โ Failure in one service doesnโt bring down the entire system.
โ
Technology flexibility โ Different services can adopt different technologies.
๐น Disadvantages
โ ๏ธ Complexity โ Managing many services, deployments, and inter-service communication is harder.
โ ๏ธ Operational overhead โ Needs strong DevOps practices (CI/CD, containerization, monitoring, logging).
โ ๏ธ Network dependency โ More API calls across services โ latency and failure handling needed.

How Docker Works Containerization/Architecture:

Before Docker we have to install all dependencies in all environments invidually

After Docker for application run we can create image along with his dependencies
eg: war+Java+Tomcat+Mysql = Image (That process called as Containerization)
๐น What is Containerization?
Containerization is the process of packaging an application and all its dependencies (libraries, configs, runtime, etc.) into a container so that it can run consistently across different environments.
It ensures that your application works the same on developer laptop, test server, or cloud.
๐น Benefits of Containerization
โ
Portability โ โBuild once, run anywhere.โ
โ
Consistency โ Eliminates โworks on my machineโ problem.
โ
Lightweight โ Uses fewer resources than VMs (no full OS inside each container).
โ
Scalability โ Easy to scale containers up/down in microservices or cloud environments.
โ
Faster deployment โ Containers start in seconds vs minutes for VMs.
How Docker Works?

First we need to pull the base image from registry and make some modification using Dockefile. Once we build the Dockerfile, it will create docker image and we can run the image to create a container.
NOTE: To create a container, we need image.
Docker Architecture:

Docker architecture majorly contains this 3 components
Client
Host
Registry
Docker Client: The Docker client is used by users which interact with Docker, when we use such commands to create a container, start the container or delete the container, the client sends these commands to Docker Daemon to perform that particular action.
Docker Host: It is a system where we installed a docker. Ex: EC2 instance, Azure VM, Personal Lappy etc..
Docker Registry: It is used to store and share the docker images. In registry we can store our images on public or private.it completely stored in cloud.

๐น What is Docker Daemon?
The Docker Daemon (
dockerd) is a background process that runs on the host machine and manages all Docker-related activities.It is responsible for:
Building images
Running containers
Managing networks & volumes
Communicating with registries (Docker Hub, private registries)
๐น How it Works
The Docker Client (
dockerCLI) does not do the heavy lifting itself.Instead, the client sends commands (via REST API, socket, or HTTP) to the Docker Daemon.
The daemon executes those commands and returns the result.
๐น Key Responsibilities of Docker Daemon
Container lifecycle management
Create, start, stop, pause, delete containers.
Example:
docker runโ Daemon creates and starts a container.
Image management
Build images from Dockerfiles.
Pull/push images to/from registries.
Networking
- Create and manage networks between containers.
Storage
- Handle volumes for persistent storage.
API Server
- Exposes the Docker Remote API so external tools (Kubernetes, CI/CD pipelines) can interact with Docker.
Docker install process:
Take an EC2 instance and launch install Docker in server (yum install docker -y)

Client : Where we execute commands
Is the docker daemon running? then start the docker systemctl start docker
docker images : to see images
docker ps : to see containers
if we have image and then if we run the image then container will create inside container application will run.
Lets pull some images from dockerhub
docker pull nginx โ> to pull image (ngnix some application or web server)

For e.g:
How images created and container:
DevOps engineer written a Jenkins docker file then build it will create image and will be push to docker hub then i pull the image from docker hub if i run the image Jenkins container will create .

Lets create container using Nginx image
docker run -itd --name devops -p 1111:80 nginx โโ ( to create container)
itd : interactive terminal **detached (**foreground and background process to always run in background)
-p : used for publishing the port number to access the application

Ports are used to access the application we can give anything randomly
1111:Host port( we can take anything)
container port: 80: Based on image (web server ngnix port number is 80)
run the below command to create container

docker ps : to see containers

container was created as shown above
To access the application : Public ip of server and port number as shown below.


