DevOpsIntermediate

Docker

Container platform that allows packaging applications with all their dependencies so they run identically in any environment.

Pronunciation

/ˈdɒk.ər/
"DOK-er"

What is it

Docker is a platform that packages an application together with everything it needs to run — code, libraries, configurations, and base operating system files (without the kernel) — into an image that runs as a container.

The result: the application behaves consistently on the developer’s laptop, test server, and production. Goodbye to most of the classic “it works on my machine”.

The Problem It Solves

Before Docker, deploying an application was complex because:

  • The dev’s laptop had Python 3.9, the server had Python 3.7
  • Library X worked on Linux but differently on Windows
  • Setting up a new server took hours or days

Docker encapsulates all of this. If it works in the container, it will work the same on any compatible host (same CPU architecture and a suitable kernel).

Container vs. Virtual Machine

Feature Virtual Machine Docker Container
Size Gigabytes (full OS included) Megabytes (shares the host kernel)
Startup Minutes Seconds or less
Isolation Strong (virtualized hardware, own kernel) Process-level (shared kernel)
Portability Limited High
Typical use Multiple OSes on one server Multiple apps on the same OS

Key Concepts

Dockerfile

The “blueprint” of an image. Defines what base image to use, what to install, and how to start the application.

FROM node:24-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY . .
CMD ["node", "server.js"]

Image

The result of “building” a Dockerfile. It’s immutable — a template.

Container

A running instance of an image. You can have 10 containers of the same Node.js server running simultaneously.

Docker Hub

The best-known public image registry. Like an “app store” for containers — ready-to-use images of MySQL, Nginx, Redis, etc.

Docker Compose

For applications with multiple services, Docker Compose defines everything in one file:

services:
  web:
    build: .
    ports:
      - "3000:3000"
  database:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD: secret

A single command brings up the entire infrastructure: docker compose up.

Impact on Modern Development

Docker transformed how software is built:

For developers:

  • Development environment identical to production
  • New team members productive in minutes, not days
  • Integration tests with real databases, not mocks

For operations:

  • Predictable and reversible deployments
  • Simplified horizontal scaling
  • Multiple versions of the same app running on the same server

For businesses:

  • Lower infrastructure cost (more density per server)
  • Reduced bugs caused by environment differences
  • Foundation for Kubernetes and cloud-native architectures

Docker and Kubernetes

Docker builds images and runs containers. Kubernetes orchestrates many containers at scale — distributes them across servers, restarts them if they fail, load-balances between them. They’re complementary: images built with Docker follow the OCI standard, and Kubernetes runs them with runtimes such as containerd. Docker is the brick, Kubernetes is the building.

  • DevOps - Culture and practices where Docker is a central tool
  • CI/CD - Continuous integration pipelines use Docker for reproducible builds
  • Microservices - Each microservice typically runs in its own container
  • Kubernetes - Container orchestrator at scale

Additional Resources: