📌 This article was originally published on Sherdil E-Learning. I'm republishing it here so the dev.to community can benefit too.
If you're a developer or IT professional looking for a practical Docker tutorial, this guide walks you through everything you need to go from zero containers to a working Dockerfile. Docker has changed how modern applications are built, shipped, and deployed — it's now a baseline skill for almost every DevOps and backend role.
This guide covers what Docker is, why it matters for your career, how to install it on Windows, Ubuntu, and macOS, the core concepts you need to know, hands-on commands you can run today, your first Dockerfile, and where Docker fits in the modern DevOps stack.
What is Docker?
You build a web application on your laptop. It runs fine. Your teammate pulls the code on their machine and it crashes. The reason is almost always environment differences — different Node versions, missing system libraries, a Python module installed globally on your machine but not theirs.
Docker solves this by packaging your application along with everything it needs — code, runtime, system tools, libraries, and settings — into a single isolated unit called a container. The container runs identically on any machine that has Docker installed: your laptop, a teammate's laptop, a CI runner, a production server, or a cloud platform.
The shorter version: a virtual machine ships a whole operating system per application; Docker ships just the application and its dependencies, with the host operating system shared underneath. That difference makes containers start in seconds rather than minutes and weigh megabytes rather than gigabytes.
Why Docker is a high-return skill in 2026
Four practical reasons Docker pays off fast:
- Near-default requirement in DevOps and backend job listings. Reviewing Q1 2026 listings, roughly two-thirds of DevOps roles and over half of backend developer roles list Docker as a required or preferred skill — many ATS pipelines filter resumes by it.
- High freelance rates. Containerising legacy applications, setting up CI/CD pipelines, and refactoring monoliths into microservices are typical Upwork projects paying $25 to $60 per hour for engineers who can deliver a working Docker bundle.
- Prerequisite for the major cloud platforms. AWS ECS, Azure Container Instances, and Google Cloud Run all run Docker containers under the hood, so any production cloud work eventually requires Docker fluency.
- You cannot meaningfully learn Kubernetes without Docker first. Kubernetes orchestrates Docker containers. Every cluster you deploy on is running images you built and pushed to a registry. Docker is step one of the modern DevOps career path.
Docker vs virtual machines
| Virtual Machine | Docker Container | |
|---|---|---|
| What ships | Full guest OS + app | App + dependencies only |
| OS overhead | One full OS per VM | Shared host OS kernel |
| Startup time | Minutes | Seconds |
| Size | Gigabytes | Megabytes |
| Density | ~10–20 per host | Hundreds per host |
| Use case | Isolating whole OSes / kernels | Isolating applications |
Core Docker concepts you need to know
Five terms come up constantly in Docker work. Get comfortable with these and the rest of the ecosystem makes sense.
Docker image
A read-only template that contains everything needed to run an application: the code, runtime, libraries, environment variables, and configuration files. Images are built from instructions in a Dockerfile and stored on your machine or in a registry like Docker Hub.
Docker container
A running instance of an image. When you run an image, Docker creates a container from it. You can start, stop, restart, and delete containers without affecting the underlying image. Multiple containers can run from the same image.
Dockerfile
A plain text file with step-by-step instructions for building an image. It specifies the base image (for example Ubuntu or Node.js), the commands to install dependencies, the files to copy in, and the command to run when the container starts.
Docker Hub
The largest public registry of Docker images. It hosts official images for Node.js, Python, MySQL, Nginx, Redis, and almost every other common piece of infrastructure. You pull these as base images and build on top of them.
Docker Compose
A tool for defining and running multi-container applications. Instead of running each container manually, you create a docker-compose.yml file that defines all the containers (web server, database, cache, etc.), their relationships, and their networks. One command — docker compose up — starts everything.
Installing Docker, step by step
Windows
Download Docker Desktop from docker.com/products/docker-desktop. Run the installer and enable WSL 2 when prompted. Restart your computer, then open Command Prompt or PowerShell and check the install:
docker --version
You should see Docker version 28 or newer. If you see a version number, Docker is installed correctly.
Ubuntu (official Docker apt repository)
The Ubuntu-packaged docker.io is often a major version behind. Install from the official repository instead:
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
docker --version
For full reference and other Linux distributions, see the official Docker Engine install guide.
macOS
Download Docker Desktop for Mac from docker.com and drag it into Applications. Open Docker Desktop, grant the required permissions, and confirm with docker --version. On Apple Silicon Macs, Docker Desktop runs natively on ARM64.
Your first Docker container: hands-on tutorial
Open a terminal and run your first container:
docker run hello-world
Docker pulls the hello-world image from Docker Hub and runs it. You'll see a message confirming the install is working.
Now run something more useful — an Nginx web server:
docker run -d -p 8080:80 --name my-web-server nginx
Breaking down the flags:
-
-d→ run the container in the background (detached mode) -
-p 8080:80→ map port 8080 on your machine to port 80 inside the container -
--name→ give the container a readable name -
nginx→ the image to run
Open http://localhost:8080 in a browser and you should see the Nginx welcome page.
Useful follow-up commands:
# list running containers
docker ps
# stop the container
docker stop my-web-server
# remove the container
docker rm my-web-server
Writing your first Dockerfile
Let's containerise a simple Node.js application. In a new directory, create a file named Dockerfile (no extension) with this content:
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]
Reading the Dockerfile line by line:
-
FROM node:22-alpine→ start from the official Node.js 22 image, Alpine variant for small size -
WORKDIR /app→ set the working directory inside the container to/app -
COPY package*.json ./→ copypackage.jsonandpackage-lock.jsonfirst (this enables layer caching for faster rebuilds) -
RUN npm install→ install dependencies inside the container -
COPY . .→ copy the rest of the application source -
EXPOSE 3000→ declare the port the container listens on -
CMD ["node", "app.js"]→ the command Docker runs when the container starts
Build and run the image:
docker build -t my-node-app .
docker run -d -p 3000:3000 --name my-app my-node-app
Full reference: Dockerfile reference on docs.docker.com.
Docker in the real world: how modern teams use it
Four of the most common production patterns you'll encounter:
Multi-service web apps. For e-commerce, SaaS, or marketplace applications, teams run separate containers for the web frontend, the API backend, the database, and the cache layer (Redis). Docker Compose wires them together, and the same compose file works for local development, staging, and production with only environment-variable changes.
Freelance & client deliveries. Delivering work as a Dockerised package — a docker-compose.yml plus a README — means a client runs one command (docker compose up) and has your entire application working locally. This is a major differentiator on Upwork; engineers regularly win contracts specifically because their deliverable is a one-command Docker bundle rather than a tarball with a setup README.
Environment parity. Software teams use Docker to keep development, testing, and production environments identical — which removes a large category of "works on my machine" bugs from the QA cycle.
Cloud deployments. AWS ECS, Azure Container Instances, and Google Cloud Run all accept Docker images directly. The image you build locally is the same image you push to production. No "rebuild for prod" step, no environment drift.
To deploy Docker containers on AWS, the Sherdil AWS 3-in-1 Training Bundle covers ECS deployment alongside Cloud Practitioner and Solutions Architect content.
Docker commands cheat sheet
The commands you'll use almost daily once you start building images:
| Command | What it does |
|---|---|
docker run <image> |
Create and start a new container from an image |
docker ps |
List running containers |
docker ps -a |
List all containers (including stopped) |
docker stop <name> |
Stop a running container |
docker start <name> |
Start a stopped container |
docker rm <name> |
Remove a container |
docker images |
List local images |
docker rmi <image> |
Remove a local image |
docker pull <image> |
Download an image from Docker Hub |
docker push <image> |
Upload an image to a registry |
docker build -t <name> . |
Build an image from the Dockerfile in current directory |
docker logs <name> |
View logs from a container |
docker exec -it <name> sh |
Open a shell inside a running container |
docker compose up |
Start everything in docker-compose.yml
|
docker compose down |
Stop and remove everything from compose |
docker system prune |
Clean up unused images, containers, and networks |
Full command reference: Docker CLI reference.
Frequently asked questions
Is Docker free to use?
Docker Engine is open-source and completely free. Docker Desktop is free for personal use, education, and small businesses (under 250 employees and under $10M annual revenue). Larger commercial use requires a paid Docker subscription.
Can I learn Docker without knowing Linux?
Basic Linux command-line familiarity is strongly advised. Most containers run Linux internally, and Docker commands are executed in a terminal. You don't need to be a Linux expert — comfort with cd, ls, mkdir, cat, grep, and a text editor like nano or vim is enough to start.
How long does it take to learn Docker?
The basics (images, containers, Dockerfiles, Docker Compose) take two to three weeks with daily practice. Becoming proficient enough for a junior DevOps role typically takes two to three months including hands-on projects.
Should I learn Docker or Kubernetes first?
Always Docker first. Kubernetes orchestrates Docker containers, so you need to understand containers before you can orchestrate them. A reasonable progression: one to two months on Docker, then four to six weeks on Kubernetes.
What is the difference between docker run and docker compose up?
docker run starts a single container. docker compose up starts everything defined in a docker-compose.yml — typically multiple containers (web, API, database, cache) wired together with networks and shared volumes. Use docker run for quick tests and individual services; use Compose for any real application.
Can I use Docker on Windows without WSL 2?
Modern Docker Desktop on Windows requires WSL 2 (or Hyper-V) for its backend. WSL 2 is the recommended setup and works out of the box on Windows 10 (build 19041+) and Windows 11. There is no production-grade native Windows containers experience aimed at typical developer workloads.
Next steps: from Docker to a DevOps career
Docker is the first major skill on the DevOps roadmap. After you're comfortable building and running containers, the natural progression is:
- Kubernetes — container orchestration
- Terraform — infrastructure as code
- One cloud platform — AWS is the most common starting point
For a structured deep-dive, the Docker Tutorial for Beginners (Pakistan) at Sherdil E-Learning covers Docker in depth, then takes you through Kubernetes, CI/CD, AWS, and Terraform.
About the author
Muhammad Usman Khan is a Lead Cloud Instructor at Sherdil E-Learning, holding the Alibaba Cloud ACP certification along with AWS and Azure credentials. He is an expert trainer in AWS and Google Cloud, having delivered 1,500+ hours of training across 12+ countries and successfully completed 50+ multi-cloud projects.
💬 Found this useful? Drop a ❤️ or a 🦄, and let me know in the comments what you'd like the next deep-dive to cover — Docker Compose for multi-service apps, image optimization, or moving from Docker to Kubernetes?
📖 Full original article (with diagrams + screenshots): elearning.sherdil.org/pages/docker-tutorial-pakistan-beginners
Top comments (0)