07-devops

Docker

07-devops/docker

Docker

Overview

Docker packages applications and dependencies into a repeatable runtime environment.


Why It Matters

It reduces “works on my machine” drift and makes local, CI, and production environments more consistent.


Core Concepts

  • Images define the environment.
  • Containers run the image.
  • Layers affect build speed and size.

Mental Models

Use containers to standardize runtime assumptions, not to hide design problems.


Best Practices

  • Keep images small.
  • Cache layers intentionally.
  • Separate build and runtime concerns where possible.

Common Mistakes

  • Shipping bloated images.
  • Putting secrets in images.
  • Ignoring startup and file system behavior.

Trade-offs

Docker improves consistency, but it adds an extra layer to understand and debug.


Decision Framework

NeedDocker helps?
Consistent runtimeYes
Hidden app logicNo

Examples

  • Use a container to run the same test command locally and in CI.

Checklists

  • Is the image small enough?
  • Are secrets excluded?
  • Does the container behavior match production expectations?

Senior Engineer Notes

Senior engineers use containers to reduce environmental drift, not to avoid understanding the runtime.


Further Reading

Use search, the sidebar, or the page links to keep moving.