Search tools, AI agents, MCP servers
Submit a tool

Search iThub

Search tools, categories and collections. Type at least two characters.

Explore all tools
↑ ↓ to explore resultsEnter to open · Esc to close

Containers & Kubernetes

What is containerization? How containers work, from kernel to registry

What containerization is and how containers work: namespaces, cgroups v2, image layers, OCI specs, runtimes, rootless, macOS and Windows, with a Dockerfile.

iThub Insights cover: Explainer, What is containerization?, with the iThub logo tile
On this page
  1. How is a container different from a virtual machine?
  2. What happens when you run a container?
  3. Which Linux features turn a process into a container?
  4. What is inside a container image?
  5. How do registries store and distribute images?
  6. Who does what in the container runtime stack?
  7. What are rootless containers?
  8. How do containers run on macOS and Windows?
  9. How do you write a Dockerfile?
  10. How do you keep container images small and trustworthy?
  11. When should you not containerize?
  12. How do containers relate to orchestration?
  13. Sources

Containerization is a way of packaging an application with the user-space files it needs, such as libraries, a language runtime and configuration, into an image, and running that image as an isolated process on a shared operating system kernel. Each container is an ordinary Linux process, not a small virtual machine: the kernel gives it a private view of the system and a capped share of its resources.

This guide explains the parts behind that definition, for developers who write Dockerfiles and sysadmins who run the hosts: kernel features, the image format, registries and the runtime stack.

How is a container different from a virtual machine?

A virtual machine emulates hardware: a hypervisor gives it virtual CPUs, memory and disks, and it boots its own kernel. A container skips that layer. Every container on a host shares the host's kernel, and the isolation comes from the kernel itself. That has four consequences:

  • Speed and density. Starting a container means starting a process, not booting an OS, so it takes milliseconds to seconds and one host fits far more containers than VMs.
  • Kernel compatibility. A Linux container needs a Linux kernel and a Windows container a Windows kernel. Anything else requires a VM in between.
  • Isolation strength. Escaping a VM means breaking the hypervisor. Escaping a container takes a kernel bug or a misconfiguration, such as a privileged container or a mounted Docker socket.
  • Visibility. Container processes appear in the host's process list. docker top shows the same process the host sees, with a host PID.

The two are often combined: most cloud Kubernetes nodes are VMs, and sandboxed runtimes wrap containers in lightweight VMs to get a hardware boundary back.

What happens when you run a container?

When you type docker run -p 8080:8080 myapp, four layers take part:

  1. The client. The docker CLI (or podman, nerdctl or the Kubernetes kubelet) turns your command into an API request.
  2. The engine, or high-level runtime. Docker Engine hands the work to containerd, Podman does it without a daemon, and Kubernetes nodes use containerd or CRI-O. This layer pulls the image, unpacks its layers, sets up networking and storage, and writes an OCI bundle: a root filesystem plus a config.json describing the process to start.
  3. The low-level runtime. runc, crun or youki reads the bundle, asks the kernel for namespaces and a cgroup, mounts the root filesystem, drops capabilities, applies seccomp and AppArmor or SELinux, then starts your program and exits. A small monitor (containerd's shim, or conmon for Podman) stays behind as the parent process.
  4. The kernel. From here on the container is just a process, and the kernel enforces every boundary on every system call.

The handoff between layers 2 and 3 is standardized. The Open Container Initiative, launched under the Linux Foundation in June 2015 by Docker, CoreOS and others, maintains three specifications: Runtime, Image and Distribution. Docker donated runc as the starting point (Open Container Initiative). Any compliant engine can drive any compliant runtime, and any registry can serve images from any compliant build tool.

Which Linux features turn a process into a container?

The kernel has no "container" object. A container combines separate features, each usable on its own:

Concept What it does Linux feature or spec
Isolated view Private process IDs, network stack, mounts, hostname, IPC, user IDs, cgroup root and clocks Namespaces: pid, net, mnt, uts, ipc, user, cgroup, time
Resource limits Caps and accounts for CPU, memory, disk I/O and process count cgroups v2 (memory.max, cpu.max, io.max, pids.max)
Reduced privilege Drops the parts of root's power the app does not need Capabilities
System call filter Blocks system calls the app should never make seccomp
Access control Confines file and resource access by policy, even for root AppArmor or SELinux
Layered filesystem Stacks read-only image layers under one writable layer overlayfs
Rootless mode Maps root inside the container to an unprivileged host user User namespaces, /etc/subuid
Image Packages layers and configuration, addressed by digest OCI Image Specification
Registry Stores and serves images over HTTP OCI Distribution Specification
Runtime Creates the container from a bundle OCI Runtime Specification (runc, crun, youki)
Kubernetes integration Lets the kubelet drive any compatible runtime Container Runtime Interface (CRI)

Namespaces: what the process can see

A namespace wraps a global resource so the processes inside get their own instance of it. Linux has eight types (namespaces(7)):

  • pid The container's first process is PID 1 and cannot see host processes.
  • net Its own interfaces, routes, firewall rules and ports.
  • mnt Its own mount table, so the image becomes /.
  • uts Its own hostname.
  • ipc Its own System V IPC objects and POSIX message queues.
  • user Its own user and group ID mappings, the basis of rootless containers.
  • cgroup Its own view of the cgroup tree, with its cgroup as the root.
  • time Its own offsets for the boot and monotonic clocks, used when a container is checkpointed and restored elsewhere.

A process lists its namespaces under /proc/<pid>/ns. Containers in one Kubernetes pod share a network namespace, which is why they reach each other on localhost.

cgroups v2: how much the process can use

Control groups organize processes into a hierarchy and distribute resources along it. Version 2, the default on current distributions, uses one unified tree in which each limit is a file (Linux kernel documentation): memory.max for a hard memory ceiling, cpu.max for a CPU quota, io.max for per-device I/O limits and pids.max for a process count that stops fork bombs. When a cgroup hits memory.max and nothing can be reclaimed, the OOM killer acts inside that cgroup only, which is the exit code 137 on a container killed for memory.

On Docker 29.9 you can see runtime flags land in those files:

$ docker run --rm --memory 256m --pids-limit 100 alpine:3.24 \
    cat /sys/fs/cgroup/memory.max /sys/fs/cgroup/pids.max
268435456
100

Kubernetes limits end up in the same files. Its documentation tells you to use the systemd cgroup driver for both kubelet and runtime on cgroup v2 hosts (Kubernetes documentation).

Capabilities, seccomp and LSMs: what the process may do

Root in a container is still root to the kernel unless something takes power away:

  • Capabilities Split root's privileges into about 40 units, such as CAP_NET_ADMIN or CAP_SYS_ADMIN. Docker's default set keeps 14, enough to change file ownership or switch users but not to load kernel modules or reconfigure the host network. --cap-drop=ALL plus only what the app needs is tighter.
  • seccomp Filters system calls. Docker's default profile is an allowlist that disables around 44 of more than 300 system calls, such as loading kernel modules or setting the clock (Docker documentation). Kubernetes runs pods without a seccomp filter unless the pod requests RuntimeDefault or the kubelet applies it by default.
  • AppArmor and SELinux Confine a process by policy, even as root. Docker applies a docker-default AppArmor profile on hosts such as Ubuntu. On Fedora and RHEL, Podman and CRI-O give each container its own SELinux label, so an escaped process still cannot read another container's files.

What is inside a container image?

An image is a stack of filesystem layers plus a JSON configuration, tied together by a manifest. Each layer is a tar archive, and every piece is a blob identified by the SHA-256 digest of its content. A reference like alpine@sha256:... therefore always means the same bits, while a tag like alpine:3.24 is a pointer the publisher can move. An image index adds a manifest per platform, so one tag can serve amd64 and arm64 machines.

At run time, overlayfs merges the read-only layers with one writable upper directory into a single view (Linux kernel documentation). Modifying an image file copies it up into the writable layer first; deleting one leaves a whiteout that hides it. In practice:

  • Layers are shared. Ten containers from one image use one copy of its layers on disk.
  • Deleting a file later does not shrink the image. The bytes stay in the earlier layer, which is how a secret copied in and removed later still leaks.
  • The writable layer dies with the container. Data that must survive belongs in a volume.

Not every instruction adds a layer. The image built from the Dockerfile below has 14 layers, 13 from its base and one from COPY. USER, EXPOSE and ENTRYPOINT only change the configuration, as docker history shows.

How do registries store and distribute images?

A registry is an HTTP service for blobs and manifests, with its API defined by the OCI Distribution Specification. A push uploads layers first and the manifest last. A pull reads the manifest and downloads only the blobs the client lacks, so images that share a base pull quickly. Docker Hub, GitHub Container Registry, Quay, Harbor and the cloud registries all speak this protocol.

Version 1.1 of the image and distribution specs, released in February 2024, added a subject field and a referrers API, so a registry can store signatures and attestations next to the image they describe and list them by digest (Open Container Initiative).

Who does what in the container runtime stack?

"Runtime" covers two layers. High-level runtimes manage images and many containers. containerd, a graduated CNCF project, handles the container lifecycle on a host, from pulling and storing images to running and supervising containers (containerd). Docker Engine runs on top of it. CRI-O does the same job for Kubernetes only and follows Kubernetes minor versions. Podman has no long-running daemon: each container is the child of a small monitor called conmon.

Low-level runtimes implement the OCI Runtime Specification: create the container from a bundle and get out of the way. runc, written in Go, is the reference implementation. crun, written in C, is smaller and faster and is Podman's default on Fedora. youki, written in Rust, is a CNCF sandbox project. gVisor, which intercepts system calls in a user-space kernel, and Kata Containers, which runs each pod in a lightweight VM, plug in at the same level without image changes.

Kubernetes sits on top. The kubelet talks to a high-level runtime through the Container Runtime Interface, a gRPC API, and Kubernetes 1.37 requires a CRI-conformant runtime. The built-in Docker Engine adapter, dockershim, was removed in version 1.24 (Kubernetes documentation). Docker-built images kept working because they are OCI images; only Docker Engine as a node runtime now needs the cri-dockerd adapter.

What are rootless containers?

Rootless containers run the engine and its containers as an ordinary user, so an escape lands in an unprivileged account instead of host root. The user namespace makes this possible: a process can be UID 0 inside while the kernel maps it to an unprivileged ID outside, and since Linux 3.8 creating one requires no privilege (namespaces(7)). Each user also gets a range of subordinate IDs, usually 65,536, in /etc/subuid and /etc/subgid for the container's other users.

Podman is rootless whenever a normal user runs it; Docker has a separate rootless mode. The costs: networking goes through a user-space helper such as pasta or slirp4netns, ports below 1024 need a sysctl change, and some storage and device features are missing.

Rootless describes the engine; the Dockerfile USER instruction describes the process inside. Use both: a non-root user limits what the app can do, and a rootless runtime limits what an escape can do.

How do containers run on macOS and Windows?

Linux containers need a Linux kernel, so on a Mac every tool runs a Linux VM and forwards the container API into it. Docker Desktop uses Apple's Virtualization framework or its own Docker VMM. OrbStack is a proprietary native app built around a lightweight VM. Colima and Rancher Desktop build on the Lima VM manager, and Podman uses podman machine. Kiri, an open-source Rust runtime still in beta, serves the Docker Engine API from one small VM on a Mac and runs on the host kernel on Linux.

Apple's own open-source container tool runs Linux containers as lightweight virtual machines on Apple silicon Macs with macOS 26 or later, and pulls and pushes standard OCI images (Apple on GitHub). A VM per container costs some memory and adds a VM boundary between containers.

Windows has two kinds of containers. Windows containers run Windows apps on the Windows kernel, from base images such as Nano Server and Server Core, in one of two modes (Microsoft Learn). Process isolation shares the host kernel and generally needs matching host and container Windows versions. Hyper-V isolation gives each container a small VM with its own kernel. Linux containers on Windows run in a Linux VM, usually WSL 2.

On both platforms, mind the CPU architecture. An Apple silicon Mac builds arm64 images by default, which will not run on an amd64 server unless you build both with docker buildx build --platform linux/amd64,linux/arm64.

How do you write a Dockerfile?

A Dockerfile is a build recipe whose instructions run in order, and those that change files produce a layer. Podman and Buildah read the same format and also accept the name Containerfile. Each layer is cached until its instruction or inputs change, so copy what changes rarely, such as dependency manifests, before what changes on every commit.

A multi-stage build uses several FROM lines: earlier stages hold compilers, and the final stage copies only the result (Docker documentation). A complete example for a small Go web service:

# syntax=docker/dockerfile:1

# Stage 1: build with the full Go toolchain (never shipped)
FROM golang:1.27-trixie AS build
WORKDIR /src
# Dependency files first: this layer stays cached until they change
COPY go.mod go.sum ./
RUN go mod download
# Then the source, compiled to a static binary
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/app .

# Stage 2: runtime image with no shell and no package manager
FROM gcr.io/distroless/static-debian13:nonroot
COPY --from=build /out/app /app
# Numeric UID, so Kubernetes runAsNonRoot can verify it
USER 65532:65532
EXPOSE 8080
# Exec form: no shell wrapper, so /app runs as PID 1 and gets the stop signal
ENTRYPOINT ["/app"]

We built it with Docker 29.9 for a standard-library Go module. docker build --check found no warnings, and the final image was 15 MB, against over 300 MB compressed for the golang:1.27-trixie build image. The service answered on port 8080 as UID 65532, docker exec with sh failed because there is no shell, and docker stop ended it in under a second. Add a .dockerignore so .git, secrets and build output stay out of the build context.

The exec form of ENTRYPOINT matters. The shell form ENTRYPOINT /app runs the binary under /bin/sh -c, where it may never see the stop signal, so docker stop waits 10 seconds and kills it. On a distroless base there is no shell at all.

How do you keep container images small and trustworthy?

Every package in an image is something to patch, scan and explain to an auditor:

  • Start small. Use -slim Debian variants, Alpine (musl rather than glibc, which trips up some software), distroless images with only runtime dependencies, or scratch for static binaries.
  • Pin by digest. FROM golang:1.27-trixie@sha256:... keeps builds reproducible when tags move. Let Renovate or Dependabot propose updates, and rebuild regularly to pick up fixes.
  • Keep secrets out of layers. Use RUN --mount=type=secret rather than COPY or ARG, since layers and image history are permanent.
  • Generate an SBOM. In our test, docker buildx build --sbom=true had BuildKit list every package with its Syft-based scanner. Syft alone covers existing images.
  • Scan continuously. Trivy, Grype, Docker Scout or Snyk match packages against vulnerability databases. Scan in CI and on a schedule, because new CVEs hit unchanged images.
  • Sign and verify. Sigstore's cosign signs an image by digest, with a key pair or keylessly through an OIDC identity such as a CI workflow, and stores the signature in the registry under the OCI 1.1 referrers model (Sigstore documentation). Verifying at deploy time, for example in a Kubernetes admission policy, means only images your pipeline signed can run.

When should you not containerize?

Containers add little, or get in the way, when:

  • The workload needs its own kernel. Kernel modules, a specific kernel or another OS call for a VM on a host such as Proxmox or Hyper-V.
  • You run untrusted code from many tenants. A shared kernel is a thin wall between customers. Use VMs, microVMs, gVisor or Kata Containers.
  • The app is one binary on one server. A systemd unit with DynamicUser=, resource limits and sandboxing options already uses cgroups and namespaces, with no registry or engine to maintain.
  • The app is a desktop GUI or needs specific hardware. Displays, USB devices, license dongles and some GPUs work only with extra plumbing.
  • The vendor does not support it. Some commercial software is supported only on a full OS install.
  • Nobody owns the images. An image is frozen at build time. Without regular rebuilds, it falls behind a host that installs updates.

How do containers relate to orchestration?

An engine manages containers on one host. Across several hosts, or for rolling updates, health-based restarts and service discovery, an orchestrator decides where each container runs and calls each node's runtime through the CRI. Docker Compose covers one host, and Dokploy or Coolify add deployment workflows on top of Docker. Kubernetes, often with Helm, covers clusters, while web UIs such as Arcane manage Docker and Podman hosts without one. Whether you need Kubernetes is covered in Docker vs Kubernetes, and the Containers & Kubernetes category lists engines, desktop runtimes and management tools.

Sources

Frequently asked questions

Is a container more secure than a virtual machine?

Not by default. Every container on a host relies on the same kernel, so one kernel vulnerability can expose all of them, while a VM has to get past a hypervisor. Containers can be hardened a long way with a non-root user, a rootless engine, the default seccomp profile, dropped capabilities and a read-only root filesystem. When you need a hardware boundary, run them under a sandboxed runtime or inside VMs.

Is Docker the same thing as containerization?

No. Docker is one set of tools that made containers popular. The images it builds follow the OCI image format, so Podman, containerd, CRI-O and Kubernetes run them too, and Docker Engine itself starts containers through containerd and runc.

What is the difference between an image and a container?

An image is a read-only template: a set of layers plus a configuration, identified by a digest. A container is one instance created from it, with its own writable layer, namespaces and cgroup. You can start many containers from one image, and removing a container leaves the image untouched.

Can I run Windows containers on a Linux host?

No. Windows containers call the Windows kernel, so they need a Windows Server or Windows 10 or 11 host. The reverse works with help: Linux containers on Windows run inside a Linux VM, typically WSL 2, managed by Docker Desktop, Podman or Rancher Desktop.

What is a Containerfile?

It is a Dockerfile under a vendor-neutral name. Podman and Buildah look for either file name, the instruction syntax is identical, and Docker can build one too if you pass it with the -f flag.

Why does my container stop right after it starts?

A container lives only as long as its main process. If the ENTRYPOINT or CMD exits, for example because a script launches a daemon in the background and then finishes, or the program crashes on a missing setting, the container stops with it. Run the service in the foreground and read docker logs for the error.

Are containers slower than running an app directly on the host?

For CPU and memory, the difference is negligible, because the process runs on the host kernel with no emulation. Overhead tends to show up elsewhere: NAT and port publishing on the network path, copy-up writes on the overlay filesystem, and file sharing through the VM on macOS and Windows. Volumes for write-heavy data avoid most of it.

Tools in this article

  1. DockerDocker Engine, Desktop, Hub, Scout and Build Cloud for building, sharing and running containerized appsContainers & Kubernetes42 views
  2. PodmanManage OCI containers and pods with a daemonless, rootless-capable engineContainers & Kubernetes8 views
  3. OrbStackRun Docker containers, Kubernetes and Linux machines locally on macOSContainers & Kubernetes7 views
  4. ColimaConfigure local container runtimes on macOS and Linux with a CLIContainers & Kubernetes3 views
  5. Rancher DesktopManage local containers and Kubernetes with a choice of container engineContainers & Kubernetes5 views
  6. KiriRust container runtime for macOS, Windows and Linux with the Docker Engine API, k3s and Kiri Share tunnelsContainers & Kubernetes30 views
  7. SnykDeveloper-first security: SAST, SCA, container and IaC scanningApplication Security20 views
  8. ProxmoxOpen-source KVM and LXC virtualization platformVirtualization & VDI18 views
Share this article

Facts link to their official sources. Product details can change after publication: report an error or read the editorial methodology.

Emanuel DE ALMEIDA

Written by

Emanuel DE ALMEIDA

Entrepreneur · IT consultant · Software creator

Geneva-based entrepreneur, IT consultant and creator of SuniPDF and SuniCapture. Emanuel shares practical IT, cybersecurity and software insights on iThub.

Keep reading

More guides and analysis from the iThub editors.

All insights
How to use Lima: run Linux VMs and containers on macOSHow to use Lima 2.3 on macOS and Linux: install, templates, shell, file sharing, ports, Rosetta, nerdctl and Docker, resources, fixes, and Lima vs Colima.12 open source projects for developers to know in 202612 open source projects for developers in late 2026, from Ghostty and Tauri to Langfuse and Zerobyte, with licenses and latest releases checked.Docker vs Kubernetes: which do you need?Compare Docker Compose and Kubernetes by host failure risk, scaling needs, operational cost and recovery testing.