Concepts

Docker

Container platform that packages applications with all dependencies into portable, consistent units that run identically in any environment.

seed#docker#containers#devops#packaging#portability#images

What it is

Docker is a platform that allows packaging applications into containers — lightweight units that include the code, runtime, libraries, and configuration needed to run. A container runs identically on your laptop, in CI/CD, and in production.

Key concepts

ConceptFunctionExample
ImageImmutable template with the filesystemnode:22-alpine, custom image
ContainerRunning instance of an imagedocker run my-app
DockerfileRecipe for building an imageFROM, COPY, RUN, CMD
RegistryImage repositoryDocker Hub, ECR, GHCR
VolumePersistent storage outside the containerDatabase data, uploads

Basic Dockerfile

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

Docker vs VMs

AspectDockerVM
OverheadMinimal (shares kernel)High (full OS)
StartupSecondsMinutes
SizeMBsGBs
IsolationProcessHardware

Best practices

  • Use official and minimal base images (alpine)
  • Multi-stage builds for small images
  • Don't run as root
  • One process per container
  • .dockerignore to exclude unnecessary files

Why it matters

Docker standardized application packaging. A container works the same in development, CI, and production. This consistency eliminated an entire category of environment bugs and enabled practices like CI/CD, microservices, and immutable infrastructure.

References

Concepts