Docker is just a tool in your toolbox which can help you in your development lifecycle and make you a better software developer.
You can still do everything without it but in the hard way.
What to expect from this blog post?
In this blog post, I will discuss a little bit about Virtualization, Containers and where it used before diving deep into detailed instructions on using Docker.
I will explain about Docker images, running Docker containers, Docker networking, Docker volumes and how it all works.
Why docker and containers ?
If you go back 20–30 years, you had a hardware and installed operating system (Kernel and UI) on top of that. To run an application, we had to compile the code and sort all application dependencies. If we needed another application or more capacity to accommodate application workload hikes, we had to purchase new hardware, do installation, and configuration.
Virtualization added one additional layer between the hardware and operating system called hypervisor. It allowed users to run multiple isolated applications on virtual machines with their OS.
While virtualization improved resource utilization by allowing multiple virtual machines (VMs) to run on a single physical server, it still had some inefficiencies. Each VM required its own full operating system, consuming significant resources (CPU, memory, and storage). Boot times were slow, and managing multiple VMs became complex.
Containers addressed these challenges by introducing a lightweight and efficient way to package and run applications. Unlike VMs, containers share the same operating system kernel while keeping applications isolated from one another. This eliminates the overhead of running multiple OS instances and results in faster startup times, better performance, and improved scalability.
Containers encapsulate everything an application needs—code, runtime, libraries, and dependencies—ensuring that it runs consistently across different environments, whether on a developer’s laptop, a test server, or in production.
Figure 2: Hypervisor and Containers
So what is docker ?
It is a container technology which help to bundle software and it’s dependencies togather for running consistently across different environments.
In simple words, docker is a way to package softwares so they can run on any machines (Windows, mac and linux)
Docker revolutionized the way we build software by making microservice-based application development possible.
Where is Docker Used Today ?
Since its launch, Docker has become an industry-standard technology for containerization. It is widely used across various domains, including:
Software Development & DevOps: Enables faster development cycles, CI/CD pipelines, and efficient testing environments.
Cloud Computing: Powers containerized applications in cloud platforms like AWS, Google Cloud, and Azure.
Microservices Architecture: Helps developers break applications into smaller, manageable services that can scale independently.
Edge Computing & IoT: Facilitates lightweight deployments on edge devices and embedded systems.
Big Data & AI/ML: Used for containerizing machine learning models and data pipelines for scalability.
Enterprise Applications: Modernizes legacy applications by running them in isolated, portable containers.
Figure 3: Netflix Microservice Architecture
Docker at Scale – Real World Use Cases
- Google – Running Billions of Containers Per Week
Google runs all its services including Search, Gmail, YouTube, and Maps on containers. They deploy over 2 billion containers per week, making Google one of the largest container users globally.
Their internal system, Borg, inspired Kubernetes, which now runs Docker containers worldwide.
- Netflix – Streaming to millions of Users with Docker
Netflix has a microservices architecture where thousands of services run in containers. Using Docker, they can:
Deploy updates thousands of times per day with zero downtime.
Scale instantly during peak traffic (e.g., Stranger Things premieres).
Ensure a seamless experience for 250M+ users worldwide.
- PayPal – Cutting Deployment Time by 90%
PayPal migrated from VMs to Docker containers and reduced software deployment time from hours to minutes. By using Docker, PayPal improved:
Resource utilization, saving on infrastructure costs.
Developer agility, allowing teams to ship features 3x faster.
- SpaceX – Docker in Rocket Launch Simulations
SpaceX uses Docker to simulate rocket launches and run AI-powered navigation systems. Containers help:
Test rocket software in isolated, reproducible environments.
Ensure mission-critical software runs identically across all systems.
Scale computing power as needed for complex calculations.
These examples show that Docker isn’t just a tool. it’s a critical infrastructure component powering the world’s largest applications.
Concepts in docker
Image
- A Docker Image is a blueprint for a container. It includes:
- The application code
- All dependencies (libraries, runtime, configurations)
- Instructions to run the app (like a Dockerfile)
Example: An image can be Ubuntu, Nginx, or a custom Node.js app.
- A Docker Image is a blueprint for a container. It includes:
Container
A container is a running instance of an image. It is lightweight, isolated, and can be created, started, stopped, or deleted.
Think of it like this:
- Image = Recipe
- Container = Cooked dish
Dockerfile
A Dockerfile is a text file with a set of instructions to create a Docker image. It defines:
- Base image (e.g., FROM python:3.10)
- Dependencies (e.g., RUN apt-get install)
- Application code (e.g., COPY . /app)
- Start command (e.g., CMD [“python”, “app.py”])
This ensures consistent builds across different environments.
Docker Hub
- Docker Hub is a public registry where you can find and share Docker images. Think of it as GitHub for Docker images.
- Example: You can pull a ready-made Nginx image by running:
docker pull nginx
Volume
- A Docker Volume is a persistent storage mechanism for containers. It ensures that data remains even if the container stops or restarts.
- Example: Running a MySQL database container with a volume:
docker run -d -v mysql-data:/var/lib/mysql mysql:latest
Network
- Docker provides different networking options for containers to communicate with each other and the outside world:
- Bridge (default, for isolated containers)
- Host (shares the host’s network)
- Overlay (for multi-host networking in Swarm)
- Example: Running a container on a specific network:
docker network create my_network docker run -d --network=my_network nginx
- Docker provides different networking options for containers to communicate with each other and the outside world:
Docker Compose
- Docker Compose allows you to define multi-container applications in a single
docker-compose.yml
file. - It simplifies the deployment of complex applications with multiple services.
- Docker Compose allows you to define multi-container applications in a single
Docker installation on Linux
- Installation
curl -fsSL https://get.docker.com | sh
- Allow running docker without
sudo
sudo groupadd docker sudo usermod -aG docker $USER newgrp docker
- Run a
hello-world
imagedocker run hello-world
Running a nodejs
in docker from terminal
- Create a
index.js
file with the following code
console.log("Hello world")
- Run the
node
image
docker run -it --rm -v ./:/app -w /app node:alpine3.21 sh
run
: create and run container from docker image-it
: starts a interactive shell--rm
: remove the container after user exits the shell-v
: set the volume in container for sharing host files inside it-w
: sets the current working directory
- Check
node
andnpm
version
node -v
npm -v
- Run the javascript file
node index.js
Running a MySQL
and phpmyadmin
setup in docker using docker compose
- Create a
docker-compose.yaml
file and paste the below content
services:
mysql:
image: mysql:9.2
container_name: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: RootPassword
MYSQL_DATABASE: my_database
MYSQL_USER: govind
MYSQL_PASSWORD: GovindPassword
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin:5.2
container_name: phpmyadmin
restart: always
environment:
PMA_HOST: mysql
ports:
- "8000:80"
depends_on:
- mysql
volumes:
mysql_data:
- Run the below command
docker compose up -d
- Visit
localhost:8000
in your browser
How Docker Works Internally
Docker Architecture
Docker follows a client-server architecture with three main components:
- Docker Client ( CLI or API that sends commands (docker run, docker build) to the Docker daemon. )
- Docker Daemon ( A background service (dockerd) that manages containers, images, volumes, and networks. )
- Docker Registry ( A repository like Docker Hub where images are stored and pulled from. )
Docker Image & Container
Docker Image
- A read-only template containing everything needed to run an application (OS, dependencies, app code).
- Built using a Dockerfile.
- Can be stored in a registry and shared.
Docker Container
- A running instance of an image.
- Uses UnionFS (OverlayFS, AUFS, etc.) for efficient layered storage.
- Isolated from the host using namespaces and cgroups.
How Docker Runs a Container
When you run docker run node, Docker performs these steps:
Pulls the Image
Checks local storage; if not found, pulls from Docker Hub.
Creates a Container
- Assigns a unique container ID.
- Sets up a filesystem using UnionFS (copy-on-write layers).
- Allocates namespaces for isolation (PID, NET, MNT, IPC, UTS).
- Applies cgroups to limit CPU & memory usage.
- Creates a virtual network interface (bridge mode by default).
Executes the Process
Runs the specified command (e.g., node app.js).
Manages Lifecycle
- When stopped, the container remains.
- When removed (docker rm), the container’s writable layer is deleted.
Namespaces are a feature of the Linux kernel that partition kernel resources such that one set of processes sees one set of resources, while another set of processes sees a different set of resources.
In Linux, cgroups (control groups) are a kernel feature that allows administrators to limit, account for, and isolate the resource usage (CPU, memory, disk I/O, network bandwidth) of a collection of processes
Alternatives
Resources
- Public container registry hub.docker.com
- A simple terminal UI for both docker and docker-compose Lazydocker
- Docker Playlist
- YouTube Channels
Recommendation
If you really want to know in deep how docker containers works then building is the best way to learn.
Liz rice a Software engineer and a member of CNCF’s Governing Board shows Building a container from scratch in Go in a 40 min video.