Skip to the page

Containers, Dockerfiles and layers · core

Containers vs VMs, images vs containers

A container is a normal process isolated with Linux namespaces and limited with cgroups, sharing the host's kernel and started from an image (a read-only stack of layers), so it starts in seconds and packs densely, while a virtual machine boots a whole guest operating system.

The notes

What you must know

  • Image: a read-only template (layers plus settings such as CMD, ENV, USER). Container: a running or stopped instance of an image with a thin writable layer on top.
  • Isolation: namespaces (process ids, network, mounts, users); limits: cgroups (CPU, memory). Containers share the host kernel, so isolation is weaker than a VM's. On macOS and Windows, Docker Desktop runs Linux containers inside a small Linux VM.
  • Why teams use containers: the same artifact runs on a laptop, in CI and in production; fast start; dependencies isolated per app; orchestrators (ECS, Kubernetes) scale and restart them.
  • Containers are disposable: the writable layer is lost when the container is removed. Keep data in volumes or external services (RDS, S3).
  • Registries (Docker Hub, GitHub Container Registry, Amazon ECR) store images. A tag (node:24-slim) is a movable name; a digest (sha256:...) never changes.
  • Images follow the OCI standard, so they also run on containerd, Podman and Kubernetes. Docker Engine 29 is current and uses the containerd image store by default.

The red pen

Common traps: mistake → fix

  • Mistake: Containers are lightweight VMs

    Fix: they are isolated processes sharing the host kernel; no guest OS boots.

  • Mistake: Data written inside a container is safe

    Fix: it disappears with the container; use volumes or external storage.

  • Mistake: Docker and Kubernetes are the same thing

    Fix: Docker builds and runs containers; Kubernetes schedules and manages them across many machines.

Easy to hard

Questions interviewers ask, easy to hard

  1. What is a container? How is it different from a VM?
  2. Image vs container?
  3. Why did your team adopt Docker? What problem did it solve?
  4. Where does the data of a Postgres container live, and what happens when you remove it?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview