# Docker for Beginners: A Complete Guide for Pakistani Developers

> 📌 **Originally published on** [**Sherdil E-Learning**](https://elearning.sherdil.org/pages/docker-tutorial-pakistan-beginners)**.** Republishing here so the Hashnode community can find it.

Every developer has hit this problem: code that runs fine locally but fails on a teammate's machine because of environment differences, a different Node version, a missing system library. Docker solves this by packaging your application along with everything it needs into an isolated **container** that runs identically on any machine that has Docker installed.

This guide covers installing Docker on Windows, Ubuntu, and macOS, the core concepts, practical commands, writing your first Dockerfile, and where Docker fits in a DevOps career.

* * *

## What is Docker?

Docker packages applications with their complete dependencies into containers. Unlike virtual machines, which include an entire operating system per application, Docker ships just the application and its dependencies, with the host operating system shared underneath. That architectural difference is why containers start in seconds rather than minutes, and take up megabytes instead of gigabytes.

* * *

## Why Pakistani developers should learn Docker in 2026

**Job market demand.** Roughly two-thirds of DevOps roles and over half of backend developer roles list Docker as a required or preferred skill, based on Q1 2026 listings on Rozee.pk and LinkedIn Pakistan.

**Freelance income.** Containerization and CI/CD pipeline work pays $25 to $60 per hour for certified Pakistani engineers in 2026 on Upwork and Fiverr.

**Cloud platform integration.** AWS ECS, Azure Container Instances, and Google Cloud Run all run Docker containers under the hood.

**Kubernetes prerequisites.** Docker is step one of the modern DevOps career path, Kubernetes orchestrates Docker containers, so you need Docker first.

* * *

## Docker vs. virtual machines

| Feature | Docker Container | Virtual Machine |
| --- | --- | --- |
| Startup Time | Seconds | Minutes |
| Size | 50–500 MB | 5–20 GB |
| Operating System | Shares the host kernel | Full OS per VM |
| Performance | Near-native speed | Slower (hypervisor overhead) |
| Isolation | Process-level | Hardware-level |
| Portability | Runs anywhere Docker runs | Tied to the hypervisor |
| Typical Use Case | Microservices, CI/CD, dev environments | Legacy apps, full OS isolation |
| Resource Footprint | Lightweight, run dozens | Heavy, run a few |

* * *

## Core Docker concepts

**Docker Image**: a read-only template containing everything needed to run an application: the code, runtime, libraries, environment variables, and configuration files. Images are built from Dockerfile instructions and stored locally or in registries like [Docker Hub](https://hub.docker.com).

**Docker Container**: a running instance of an image. When you run an image, Docker creates a container from it, and multiple containers can run from the same image independently.

**Dockerfile**: a plain text file with step-by-step instructions for building an image: base image, dependency installation, file copying, and the startup command.

**Docker Hub**: the largest public registry of Docker images, hosting official images for Node.js, Python, MySQL, Nginx, Redis, and most common infrastructure components.

**Docker Compose**: a tool for defining and running multi-container applications. Instead of managing containers one by one, one command, `docker compose up`, starts everything defined in a `docker-compose.yml` file.

* * *

## Installing Docker, step by step

### Windows

Download Docker Desktop from [docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop/), enable WSL 2 when prompted, and restart. Verify with `docker --version` (version 28 or newer required).

### Ubuntu

Install from the official Docker apt repository rather than the Ubuntu-packaged `docker.io` (see the [Docker Engine install guide](https://docs.docker.com/engine/install/) for the latest steps):

```bash
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
```

### macOS

Download Docker Desktop for Mac from [docker.com](https://www.docker.com/products/docker-desktop/), drag it to Applications, open it, grant permissions, and confirm with `docker --version`. Apple Silicon Macs get native ARM64 support.

* * *

## Your first Docker container

**Hello World test:**

```bash
docker run hello-world
```

**Running an Nginx web server:**

```bash
docker run -d -p 8080:80 --name my-web-server nginx
```

The flags: `-d` runs the container in the background (detached mode), `-p 8080:80` maps port 8080 on your machine to port 80 inside the container, `--name` gives the container a readable name. Visit `http://localhost:8080` to see it running.

**Useful follow-up commands:**

```bash
# 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

For a Node.js application:

```dockerfile
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]
```

Line by line: `FROM node:22-alpine` starts from the official Node.js 22 image, Alpine variant for compact size. `WORKDIR /app` sets the container's working directory. `COPY package*.json ./` copies package files first, a layer-caching optimization. `RUN npm install` installs dependencies. `COPY . .` copies the application source. `EXPOSE 3000` declares the listening port. `CMD ["node", "app.js"]` is the startup command. (Full reference: [Dockerfile reference on docs.docker.com](https://docs.docker.com/reference/dockerfile/).)

Build and run it:

```bash
docker build -t my-node-app .
docker run -d -p 3000:3000 --name my-app my-node-app
```

* * *

## How Pakistani teams actually use Docker

**E-commerce and marketplace applications** run separate containers for frontend, API backend, database, and a cache layer (Redis), with Docker Compose wiring them together for consistent development, staging, and production environments.

**Freelance projects.** Delivering work as a Dockerized package, a `docker-compose.yml` plus a README, means the international client runs one command (`docker compose up`) and has your entire application working. This is a real competitive advantage on Upwork.

**Software houses** use Docker to keep identical development, testing, and production environments, which removes a large category of "works on my machine" bugs from the QA cycle.

**Cloud deployments.** The image you build locally is the same image you push to production on AWS ECS, Azure Container Instances, or Google Cloud Run.

* * *

## Docker commands cheat sheet

| Command | Purpose |
| --- | --- |
| `docker pull <image>` | Download an image from Docker Hub |
| `docker run <image>` | Create and start a new container |
| `docker ps` | List running containers |
| `docker ps -a` | List all containers (including stopped) |
| `docker stop <name>` | Stop a running container |
| `docker rm <name>` | Delete a stopped container |
| `docker images` | List downloaded images |
| `docker rmi <image>` | Delete an image |
| `docker build -t <name> .` | Build an image from a Dockerfile in the current directory |
| `docker compose up` | Start all services defined in docker-compose.yml |
| `docker exec -it <name> bash` | Open a shell inside a running container |
| `docker logs <name>` | View a container's stdout/stderr |

(Full reference: [Docker CLI reference on docs.docker.com](https://docs.docker.com/reference/cli/docker/).)

* * *

## 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 $10 million 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. Competency with basic commands like `cd`, `ls`, `mkdir`, `cat`, and `grep`, plus a text editor, is enough to begin.

### 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. Recommended 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 file, typically multiple containers (web, API, database, cache) wired together. Use `docker run` for quick tests, Compose for production applications.

### 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.

* * *

## From Docker to a DevOps career

Docker is the first major skill on the DevOps roadmap. After mastering containers, the progression continues with Kubernetes (container orchestration), Terraform (infrastructure as code), and one cloud platform, AWS is the most common starting point in Pakistan.

The [DevOps Engineer Course at Sherdil E-Learning](https://elearning.sherdil.org/courses/devops-engineer-cert-urdu) covers Docker, Kubernetes, CI/CD, AWS, and Terraform in Urdu. The AWS 3-in-1 Training Bundle includes ECS deployment. For the full career path, read the DevOps Career Roadmap for Pakistan and Kubernetes vs Docker: Differences Explained.

* * *

## About the author

**Muhammad Usman Khan** is a Lead Cloud Instructor at [Sherdil E-Learning](https://elearning.sherdil.org), 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 completed 50+ multi-cloud projects.

* * *

**Found this useful?** Follow for upcoming deep-dives on **writing production-ready multi-stage Dockerfiles** and **Docker Compose for local microservices**.

📖 **Full original article (with the complete command reference and installation guides):** [elearning.sherdil.org/pages/docker-tutorial-pakistan-beginners](https://elearning.sherdil.org/pages/docker-tutorial-pakistan-beginners)
