What Is Docker and Why Do Developers Love It?

Docker is a platform that lets you package applications and their dependencies into lightweight, portable units called containers. The famous developer promise: "It works on my machine" becomes "It works on every machine" — because the environment travels with the application.

Whether you're eliminating environment inconsistencies, simplifying onboarding, or preparing apps for cloud deployment, Docker is a foundational tool worth learning early.

Key Concepts Before You Start

Images

A Docker image is a read-only template — a blueprint that defines what's inside a container. Images are built from instructions in a Dockerfile and can be stored in registries like Docker Hub.

Containers

A container is a running instance of an image. You can run many containers from the same image simultaneously. Containers are isolated from each other and from the host machine by default.

Dockerfile

A Dockerfile is a plain-text script containing commands that Docker uses to build an image. It defines the base OS, installs dependencies, copies your application code, and specifies how the app should run.

Docker Hub

Docker Hub is a public registry of Docker images. You can pull official images for databases, web servers, programming language runtimes, and more — instantly, with a single command.

Installing Docker

Download Docker Desktop from docker.com for Windows and macOS. It includes the Docker Engine, CLI, and a graphical dashboard. On Linux, install Docker Engine directly through your package manager. Verify installation with:

docker --version
docker run hello-world

If you see a success message from the hello-world container, you're ready to go.

Essential Docker Commands

CommandWhat It Does
docker pull <image>Downloads an image from Docker Hub
docker run <image>Creates and starts a container from an image
docker psLists currently running containers
docker ps -aLists all containers (including stopped ones)
docker stop <id>Stops a running container
docker build -t myapp .Builds an image from the current directory's Dockerfile
docker exec -it <id> bashOpens an interactive shell inside a running container
docker logs <id>Shows the output logs of a container

Your First Dockerfile

Here's a minimal Dockerfile for a Node.js application:

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

Breaking this down:

  • FROM: Starts from the official Node.js 20 Alpine (lightweight Linux) image.
  • WORKDIR: Sets the working directory inside the container.
  • COPY + RUN: Copies package files and installs dependencies.
  • EXPOSE: Documents which port the app listens on.
  • CMD: The command that runs when the container starts.

Introduction to Docker Compose

Real applications rarely run as a single container. A web app might need a Node.js server, a PostgreSQL database, and a Redis cache running together. Docker Compose lets you define and manage multi-container applications in a single docker-compose.yml file, then start everything with one command: docker compose up.

When to Use Docker

  • Standardizing development environments across a team.
  • Running services (databases, message queues) locally without installing them natively.
  • Deploying applications to cloud platforms like AWS, GCP, or Azure.
  • Building CI/CD pipelines that need consistent, reproducible environments.

Next Steps

Once comfortable with single-container workflows, explore Docker Compose for local development, and then look into Kubernetes for orchestrating containers at scale in production environments. Docker is the first step in a broader container ecosystem that powers much of modern cloud infrastructure.