Introduction
If you’ve ever built an application that worked perfectly on your computer but failed on another machine, then you’ve experienced one of the biggest problems in software development “inconsistent environments”.
Maybe your project depended on a specific version of Python, Node.js, Java, or a database that wasn’t installed on another computer. Developers often spend hours trying to recreate the same development environment before they can even begin writing code.
This is exactly the problem Docker solves.
Docker allows developers to package an application together with everything it needs to run, the code, libraries, dependencies, configurations, and runtime into a portable package called a container.
The result is simple:
Build once, run anywhere.
Whether you’re running your application on Windows, macOS, Linux, a cloud server, or a teammate’s laptop, Docker helps ensure it behaves the same way.
Containerization
Containerization is a method of packaging software so it can run consistently across different environments.
Instead of installing every dependency manually on each machine, everything the application needs is bundled together inside a container. No matter what application is inside, Docker knows how to run it consistently.
Docker
Docker is an open source platform that helps developers build, package, distribute, and run applications inside containers.
Docker provides all the tools needed to create containers, manage them, and deploy applications with minimal setup. Instead of worrying about operating systems, dependencies, or configuration differences, developers focus on writing code.
Docker Architecture
Docker is made up of several important components. Understanding these components makes Docker much easier to learn.
Docker Engine
The Docker Engine is the core software that powers Docker. Think of Docker Engine as the “brain” of Docker.
It is responsible for:
- Building Docker images
- Creating containers
- Running containers
- Managing networks
- Managing storage volumes
Whenever you type a Docker command like:
docker run nginx
Docker Engine receives the command and performs all the necessary operations behind the scenes.
Without Docker Engine, Docker cannot function.
Docker Image
A Docker Image is a blueprint or template used to create containers. Images are read only. You don’t run an image directly. Instead, Docker creates a container from an image.
It contains:
- Application code
- Runtime
- Libraries
- Dependencies
- Environment variables
- Configuration files
One Docker image can create many containers.
Example:
docker pull nginx
This downloads the official Nginx image.

Docker Container
A Docker Container is a running instance of a Docker image. Once an image starts running, it becomes a container. Containers are lightweight and isolated from the host operating system.
You can:
- Start containers
- Stop containers
- Restart containers
- Delete containers
- Create multiple containers from one image
Example:
docker run nginx
This starts a new container using the Nginx image.

Dockerfile
A Dockerfile is a text file containing instructions for building a Docker image. Instead of creating images manually, developers define the steps inside a Dockerfile.
Example:
FROM node:20
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]
This tells Docker:
- Start from the Node.js image
- Create a working directory
- Copy project files
- Install dependencies
- Expose port 3000
- Start the application
To build the image:
docker build -t my-app .
Docker Hub
Docker Hub is an online registry where Docker images are stored and shared. It works similarly to GitHub, but instead of storing source code, it stores Docker images.
You can:
- Download official images
- Upload your own images
- Share images publicly or privately
Popular images include:
- nginx, mysql, postgres, redis, node, ubuntu, python,
To download an image:
docker pull nginx

Docker Ports
Applications inside containers run in their own isolated environment. To access them from your computer, Docker maps container ports to ports on the host machine.
Example:
docker run -p 8080:80 nginx
This means:
- Port 80 is inside the container.
- Port 8080 is on your computer.
Visiting:
http://localhost:8080
will display the Nginx web page.
Docker Volumes (Optional but Useful)
Containers are temporary. If a container is deleted, its data is also deleted unless it is stored in a Docker Volume. Volumes allow data to persist.
Example:
docker volume create mydata
Installing Docker
The installation process depends on your operating system.
Windows
- Download Desktop Docker
- Run the installer.
- Enable WSL 2 if prompted.
- Restart your computer.
- Open Docker Desktop.
- Wait until Docker starts successfully.
Verify installation:
docker --version or docker version

macOS
- Download Docker Desktop for macOS.
- Install the application.
- Launch Docker Desktop.
- Wait until Docker finishes starting.
Verify:
docker --version
Ubuntu Linux
Update packages:
sudo apt update
Install Docker:
sudo apt install docker.io
Enable Docker:
sudo systemctl enable docker
sudo systemctl start docker
Verify:
docker --version
Run without sudo (optional):
sudo usermod -aG docker $USER
Then log out and log back in.
Your First Docker Deployment
Let’s deploy a simple static web landing page using Docker.
Step 1: search the docker hub for an image
docker pull nginx
Docker downloads the latest Nginx image from Docker Hub.

Step 2: Start a Container
docker run -d -p 8088:80 --name welcome-to-docker docker/welcome-to-docker
Here’s what each option means:
- -d runs the container in the background (detached mode).
- -p 8080:80 maps your computer's port 8080 to the container's port 80.
- --name welcome-to-docker gives the container an easy name to remember .
- docker/welcome-to-docker is the image used to create the container.

Step 3: Verify the Container is Running
docker ps
You should see your running container listed.
Press enter or click to view image in full size
Step 4: Open Your Browser
Visit:
http://localhost:8088
You should see the congratulation page.


Congratulations you’ve deployed your first application using Docker!
Step 5: Stop the Container
docker stop my-nginx
Step 6: Start It Again
docker start my-nginx
Step 7: Remove the Container
docker rm my-nginx
If the container is still running, stop it first.
Summary
Through containerization, anyone can package applications and their dependencies into portable, lightweight containers that run consistently across different environments. With these fundamentals in place, you’re ready to explore more advanced Docker topics such as Docker Compose, custom image creation, networking, volumes, and multi-container applications.