M. Kodirov

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, 2017

Containerizing workloads

Netflix described how its use of containers evolved and how Titus supported container workloads.

  1. Application workload
  2. Container image
  3. 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 evolution

GitHub

GitHub engineering, 2023

Build containerized services

GitHub described a process for building and releasing its containerized services using GitHub-based tooling.

  1. Service source
  2. Container build
  3. 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 services

TRY 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

Official references.