Skip to content
Engineering Bible
Docker

Docker on containers and images

A container is an isolated process

  • It's an ordinary process on your machine, such as a Node.js server, fenced off from the rest.
  • It gets its own filesystem and its own view of the system. It can't see other containers.
  • Two Linux kernel features do this: namespaces limit what it sees, cgroups what it uses.
  • The app ships with everything it needs, so it runs the same on any machine with Docker.

A container shares the host's kernel, a VM brings its own

  • A virtual machine (VM) pretends to be a whole computer and boots a full operating system.
  • A container has no operating system to boot. It starts as fast as a process starts.
  • The trade-off: containers are kept apart only by the kernel they all share.
Virtual machineContainer
KernelIts own, one per VMThe host's, shared
To startBoots an operating systemStarts one process
Kept apart byA pretend computerThe shared kernel

An image is the package a container starts from

  • An image holds everything a container needs to start: the app, its runtime and its files.
  • Once built, an image never changes. One image can start any number of containers.
  • The format is an open standard (OCI), so tools other than Docker can build and run images.

An image is a stack of layers

  • Each layer is a set of file changes: add these files, change those.
  • Layers are stored by a hash of their contents, so identical layers are stored once.
  • Every image built on node:24-slim reuses that image's layers instead of copying them.
  • A container adds one thin writable layer on top. Removing the container deletes it.
  1. Writable layerone per container, not in image
  2. RUN npm ciyour dependencies
  3. COPY package*.json ./your dependency list
  4. WORKDIR /appyour app folder
  5. node:24-slim layersshared with other images
Everything below the top is the read-only image. Each container gets its own writable layer.

An image name says where it lives and which version

  • The full form is registry/namespace/repository:tag, like ghcr.io/acme/todo-app:1.0.
  • Leave parts out and Docker fills them in: nginx means docker.io/library/nginx:latest.
  • A tag is a label that can be moved to a newer image. latest is only the default tag.
  • A digest, written @sha256:..., is a hash of the image, so it always means the same one.
Docker in four pages1 / 4