What you'll learn
- Explain containers versus virtual machines and the OCI standards
- Isolate processes with namespaces and limit them with cgroups
- Build, read and run an OCI image by hand
- Explain layers, copy-on-write, networking and registries
- Harden containers: non-root, read-only, capabilities, seccomp, limits
Each lesson is tagged Junior, Mid or Expert, so you can start where you are. Finish with the lab and the quiz; a score of 4 out of 5 marks the course complete in this browser.
The lessons below are in English for now, because they quote technical names, commands and log fields. An Arabic version is planned.
Course map
Each module moves from fundamentals to applied work to an expert challenge. Exercises have worked solutions: try first, then open the solution. 10 modules · 17 exercises · ~3.8 hours
- 0Start here: what a container really isJuniorMidExpert20 min · 0 exercises
- 1Namespaces: isolating what a process can seeJuniorMidExpert25 min · 2 exercises
- 2cgroups: limiting what a process can useJuniorMidExpert20 min · 2 exercises
- 3Images: layers, manifests and digests (OCI image format)JuniorMidExpert30 min · 2 exercises
- 4Runtimes: from image to running containerJuniorMidExpert30 min · 2 exercises
- 5Layered file systems and copy-on-writeJuniorMidExpert20 min · 2 exercises
- 6Container networkingJuniorMidExpert20 min · 2 exercises
- 7Registries and distributionJuniorMidExpert15 min · 1 exercises
- 8Container security: isolation and hardeningJuniorMidExpert30 min · 3 exercises
- 9Choosing tools, cheat sheet and assessmentJuniorMidExpert20 min · 1 exercises
No prior experience is needed. Module 0 covers the architecture, installation and configuration, and sets up the project you extend in every module. Each command is labelled with its impact (read-only, changes files, changes the system, uses the network). Work on a computer or virtual machine you control.
Start here: what a container really is
Goal: Separate the idea of a container from any one tool, compare containers with virtual machines, and set up the lab.
A process with a different view of the system
A container is an ordinary Linux process that the kernel has given a restricted view of the system (its own process tree, file system, hostname and network) and a resource budget. An image is the packaged file system and settings it starts from.
Containers package an application with exactly the libraries it needs, start in milliseconds, and run the same way on a laptop, a CI runner and a production cluster. Because they share the host kernel, they are much lighter than virtual machines, and that also makes their security boundary different.
Docker made containers easy, but it is only one tool. The pieces are standardised by the Open Container Initiative (OCI): an image format, a runtime specification and a distribution (registry) API. Docker, Podman, containerd, CRI-O and Kubernetes all build on them.
| Virtual machine | Container | |
|---|---|---|
| Isolation | hardware virtualisation, separate kernel | kernel features on a shared kernel |
| Start time | tens of seconds | milliseconds |
| Size | gigabytes | megabytes |
| Best for | different OSes, strong tenant isolation | packaging and running services densely |
Quick check: A container image built for Linux on x86-64 runs on…
Containers share the host kernel, so the kernel and CPU architecture must match the image.
The lab and the course project
In this course you will containerise the Rimal Logistics shipment tracker (the Python API from the DevOps course) without Docker: you isolate it with namespaces, limit it with cgroups, package it as an OCI image from tar files and JSON, and run it with runc, the runtime underneath Docker and Kubernetes. Once you can do it by hand, every tool's behaviour makes sense.
sudo apt install runc jq curl util-linux python3
runc --versionUse WSL 2 with Ubuntu, then follow the Linux tab. Containers need a Linux kernel; WSL 2 provides one.
Use a Linux VM (for example colima start then colima ssh, or UTM with Ubuntu), then follow the Linux tab.
Commands that change kernel state need root, so they start with sudo. All outputs in this course were produced by running these exact commands.
uname -s
ls /proc/self/ns
runc --version | head -n 1Linux cgroup ipc mnt net pid pid_for_children time time_for_children user uts runc version 1.5.3
Tools in this course
Developer platform: CLI, engine, build, Compose, Desktop.
Use it for: building and running containers locally and in CI
Integrates with: containerd, BuildKit, registries
Daemonless, rootless-first engine with a Docker-compatible CLI; runs pods.
Use it for: Linux servers, rootless workloads, RHEL
Integrates with: systemd, Kubernetes YAML
Industry-standard container manager (CNCF): images, snapshots, lifecycle.
Use it for: the engine inside Docker and most Kubernetes nodes
Integrates with: runc, CRI, nerdctl
Reference OCI runtime: creates namespaces and cgroups and starts the process.
Use it for: the last step of every docker run
Integrates with: containerd, CRI-O, Podman
Orchestrator that schedules containers across many machines.
Use it for: running containers in production
Integrates with: containerd, CRI-O
Prepare the lab
Goal: Create the project folder; a setup step has copied a Python runtime from the host into base/, the equivalent of a python slim base image.
cd ~/tracker-oci && ls && du -sh base base.tar | sed 's/\t/ /'base base.tar 50M base 49M base.tar
Namespaces: isolating what a process can see
Goal: Create UTS, PID, mount and network namespaces with unshare and see exactly what each one isolates.
Free account Create a free account or sign in to continue this course.
cgroups: limiting what a process can use
Goal: Understand control groups, set memory and process limits, and observe the kernel enforcing them.
Free account Create a free account or sign in to continue this course.
Images: layers, manifests and digests (OCI image format)
Goal: Build a real OCI image by hand from two tar layers and JSON, and read every part of it.
Free account Create a free account or sign in to continue this course.
Runtimes: from image to running container
Goal: Unpack the image into a bundle, configure it with the OCI runtime spec, and run, inspect and stop it with runc.
Free account Create a free account or sign in to continue this course.
Layered file systems and copy-on-write
Goal: See how overlayfs combines read-only image layers with a writable container layer, including deletions.
Free account Create a free account or sign in to continue this course.
Container networking
Goal: Understand how isolated network namespaces get connectivity: veth pairs, bridges, NAT and port publishing.
Free account Create a free account or sign in to continue this course.
Registries and distribution
Goal: Push and pull images safely: the registry API, tags versus digests, and keeping images trustworthy.
Free account Create a free account or sign in to continue this course.
Container security: isolation and hardening
Goal: Understand where the container boundary really is, and apply non-root, read-only, capability, seccomp and resource controls.
Free account Create a free account or sign in to continue this course.
Choosing tools, cheat sheet and assessment
Goal: Choose the right engine and runtime, review the course, and prove the skills on a new service.
Free account Create a free account or sign in to continue this course.
Quick reference (the cheat-sheet lessons and the PDF content)
Containers versus virtual machines
The kernel features that make a container
| Feature | What it isolates or limits | See it |
|---|---|---|
| PID namespace | Process IDs: PID 1 inside the container | lsns -t pid |
| Network namespace | Interfaces, routes, ports | ip netns, nsenter -t PID -n ip a |
| Mount namespace | Filesystem view (the image's root) | findmnt -N PID |
| UTS, IPC namespaces | Hostname; shared memory and semaphores | hostname inside differs |
| User namespace | Root in the container maps to an unprivileged host user | /proc/PID/uid_map |
| cgroups v2 | CPU, memory, PIDs, I/O limits and accounting | cat /sys/fs/cgroup/.../memory.max |
| Capabilities | Splits root into ~40 privileges (NET_ADMIN, SYS_ADMIN …) | capsh --print |
| seccomp, AppArmor, SELinux | Which system calls and files a process may use | grep Seccomp /proc/PID/status |
Images and layers
Key facts
- Layers are read-only and shared between images: pulls and disk are cheaper
- An image is identified by its digest (
sha256:…); a tag like:1.4can be moved - Deleting a file in a later layer does not remove it from earlier layers: secrets stay in history
- Multi-arch images: one tag, a manifest list per CPU (amd64, arm64)
From build to running process
Who does what: the runtime stack
Kubernetes talks to containerd or CRI-O through the CRI. Docker-built images run everywhere because they follow the OCI image spec.
Container lifecycle and states
docker create --name web nginx:1.27 # created
docker start web # running
docker pause web; docker unpause web # frozen by cgroup freezer
docker stop web # SIGTERM, then SIGKILL after 10 s
docker rm web # writable layer deleted
docker inspect web --format '{{.State.Status}} {{.State.ExitCode}}'| Exit code | Usually means |
|---|---|
| 0 | Finished normally |
| 1 | Application error |
| 125 | The runtime command failed |
| 126 / 127 | Command not executable / not found |
| 137 | SIGKILL: out of memory or forced stop |
| 143 | SIGTERM: stopped gracefully |
Storage and networking basics
Storage
- Volumes: managed by the engine, survive the container: use for data
- Bind mounts: a host path inside the container: convenient, riskier
- tmpfs: memory only, for secrets and scratch data
- Never keep state in the writable layer
Networking
- bridge (default): private network, publish ports with
-p 8080:80 - host: shares the host network stack, no isolation
- none: no network, for batch jobs
- Containers on the same user-defined network resolve each other by name
- Bind published ports to 127.0.0.1 unless they must be public
Security boundaries in one table
| Setting | Default risk | Safer choice |
|---|---|---|
| Run as root | Root in container = root on host if it escapes | USER 10001, or rootless mode / user namespaces |
--privileged | All capabilities and devices: no real isolation | Never; add only the single capability needed |
| Writable root filesystem | Malware and tampering persist in the container | --read-only plus a tmpfs for /tmp |
| Docker socket mounted | Full control of the host | Do not mount /var/run/docker.sock |
| Image from an unknown publisher | Malware, cryptominers, old CVEs | Trusted base images, pinned digest, signed |
| No resource limits | One container starves the host | --memory, --cpus, --pids-limit |
Key terms
- Namespace
- A kernel feature that gives a process its own view of a resource: PIDs, mounts, network, hostname, users.
- cgroup
- A kernel group that measures and limits CPU, memory, processes and I/O.
- OCI image
- Layers (tar), a config and a manifest, all addressed by SHA-256 digest.
- OCI runtime (runc)
- Creates the isolated process from a bundle: rootfs + config.json.
- OverlayFS
- Read-only image layers plus a writable container layer merged into one tree.
- Capability
- One slice of root's power; containers should drop all they do not need.
Hands-on lab
Free account Create a free account or sign in to continue this course.
Knowledge check
Answer all five questions, then check your answers. Each answer comes with a short explanation.
Further reading
- OCI image specification github.com
- OCI runtime specification github.com
- runc github.com
- Linux namespaces (man 7 namespaces) man7.org
- cgroups v2 docs.kernel.org
- NIST SP 800-190 csrc.nist.gov
Put it into practice
Use these ThreatAI tools to apply what you learned to your own environment.