DevOps Intermediate

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, base operating system — into a unit called a container.

The result: the application runs exactly the same on the developer’s laptop, test server, and production. No more “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 works anywhere.

Container vs. Virtual Machine

FeatureVirtual MachineDocker Container
SizeGigabytes (full OS included)Megabytes (shares host OS)
StartupMinutesSeconds
IsolationFull (emulated hardware)Process (shared kernel)
PortabilityLimitedHigh
Typical useMultiple OSes on one serverMultiple apps on the same OS

Key Concepts

Dockerfile

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

FROM node:20
WORKDIR /app
COPY package.json .
RUN npm install
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 public repository of Docker images. Like the “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:15
    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 creates 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: 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 for Docker at scale

Additional Resources: