ProductionIntermediate6h

Docker basics.

Images, containers, and reproducible runtime environments.

What is Docker?

Docker packages your application and everything it needs to run — runtime, libraries, config — into an image. That image runs the same way on your laptop, in CI, and in production. It is the standard answer to "works on my machine."

Why it matters

Containers make environments reproducible and deploys predictable, which is why they underpin most modern infrastructure. Even if a platform hides Docker from you, understanding images and layers helps you build smaller, faster, more secure deployments. It is a baseline backend skill in 2026.

What to learn

  • Images vs containers vs registries
  • Writing a Dockerfile and how layers cache
  • Multi-stage builds to shrink the final image
  • .dockerignore and build context
  • Environment variables and ports at run time
  • Running as a non-root user
  • Docker Compose for local multi-service setups

Common pitfall

Building bloated images by copying everything and installing dev tooling into the final stage. A multi-stage build that copies only the built artifact and production dependencies can cut an image from gigabytes to tens of megabytes — faster to ship, smaller attack surface. Order layers so dependencies cache.

Resources

Primary (free):

Practice

Write a multi-stage Dockerfile for your Node API: build in one stage, copy only the output and production dependencies into a slim final stage, and run as a non-root user. Build the image, check its size, and run the container locally. Done when the final image is small and the app responds.

Outcomes

  • Explain images, containers, and registries.
  • Write a Dockerfile that caches layers efficiently.
  • Shrink an image with a multi-stage build.
  • Run a container as non-root with config from the environment.
Back to Backend roadmap