STAGE 06 / LESSON 02
Docker images and containers
An image packages an application and its runtime; a container is a running instance of that image.
THE IDEA
Understand it.
A Dockerfile describes how to build an image. The image can then run consistently across environments, though configuration, secrets, operating-system architecture and external services still matter.
Use a .dockerignore to exclude unnecessary files and secrets, run with least privilege, and keep base images patched. Docker Compose can describe multiple local services, such as an app and a development database.
SEE IT IN CONTEXT
A small illustrative Node image
FROM node:24-alpine
WORKDIR /app
COPY --chown=node:node package*.json ./
RUN npm ci --omit=dev
COPY --chown=node:node . .
USER node
CMD ["node", "server.js"]This assumes package-lock.json and a server.js that needs only production dependencies. Pin and update an appropriate base image for a real release.
LEARN FROM REAL WEBSITES
See it in the real world.
These simplified structures come from public sources. Company systems change, and the sources may describe only one project or an earlier design.
Netflix
Netflix engineering, 2017Containerizing workloads
Netflix described how its use of containers evolved and how Titus supported container workloads.
- Application workload
- Container image
- Titus platform
What to learn: An image packages an application for execution in a container; Netflix's article describes its historical platform decisions.
Read the source: Netflix container evolutionGitHub
GitHub engineering, 2023Build containerized services
GitHub described a process for building and releasing its containerized services using GitHub-based tooling.
- Service source
- Container build
- Containerized service
What to learn: A build process turns source into a deployable image; images and running containers are related but distinct.
Read the source: GitHub containerized servicesTRY IT YOURSELF
Practice.
Why should .env files and node_modules usually be excluded from the build context?
Show one possible answer
Excluding them reduces accidental secret exposure and avoids copying machine-specific dependencies into the image. Use a reviewed .dockerignore and separate secret handling.
GO DEEPER