Containers and orchestration
Containers from the inside
Namespaces, cgroups and layered images - what a container really is, how images are built and shipped, and how to write small, fast, secure Dockerfiles.
A container is an ordinary Linux process that the kernel isolates. It sees its own process tree, network interfaces, root filesystem and hostname. It may use only a fixed slice of CPU and memory. It shares the host's kernel with every other container on the machine.
That one fact explains most of what containers do. They start in milliseconds, images can be 20 MB, and a kernel bug in one container can reach the host.
Containers are the unit of deployment for most production work. Kubernetes schedules them, serverless platforms run them, and your CI pipeline builds, scans and signs them. Once you know the moving parts, odd cases like exit code 137 or a process that ignores SIGTERM stop being mysteries.
The concept pages
| Step | Concept | What it answers |
|---|---|---|
| 1 | Containers vs virtual machines | Why is a container lighter than a VM, and what does it give up? |
| 2 | Namespaces and cgroups | How does a process see its own world and stay within limits? |
| 3 | Image layers and digests | How is an image stored, and why does a tag not pin anything? |
| 4 | Writing good Dockerfiles | How do you order steps so builds are fast and images are small? |
| 5 | Container security | What do you lock down, and why is a container not a sandbox? |
| 6 | Shrinking an image | How do you take a 1.2 GB image to under 150 MB? |
Local development with Compose
Docker Compose runs several containers from one compose.yaml: your app, a database, a cache. The containers reach each other by service name on a private network.
services:
api:
build: .
depends_on:
db:
condition: service_healthy
db:
image: postgres:16
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 2s
retries: 15A plain depends_on waits for the database container to start, not to accept connections, so use the healthcheck condition. Compose is for development and CI. In production the same images run on Kubernetes or a managed runtime.
Common mistakes across the topic
- Using the shell form of
CMD. The app never receivesSIGTERM, so it is killed after the grace period. - Deploying by a mutable tag such as
latest. The bytes behind the tag can change under you. - Putting a secret in a
RUNstep. Even if a later step deletes it, the earlier layer still holds it. - Treating the container as a sandbox for untrusted code. It is a convenience boundary, not a strong one.
Key takeaways
- A container is a normal process, isolated by namespaces and limited by cgroups, sharing the host kernel.
- Images are stacks of content-addressed layers. Deleting a file in a later layer does not shrink the image.
- Order Dockerfile steps from least to most often changed, and use multi-stage builds on slim or distroless bases.
- Deploy by digest, and harden with minimal images, a non-root user, a read-only filesystem and dropped capabilities.
Further learning
Docker: Get started covers the basic commands. The next page is containers vs virtual machines, which explains why the shared kernel matters.
Related
Processes, threads and the kernel
What the OS gives every program, and how to see it on a live Linux box. Start here for the process model.
Kubernetes core concepts
The control loop at the heart of Kubernetes, the objects you use every day, and how a request reaches a pod. Start here for the map of Kubernetes pages.
Continuous integration and the software supply chain
Fast, trustworthy pipelines - build, test, artifact, scan and sign - plus DORA metrics and supply-chain controls that keep trunk green.