Docker Tutorial — Introduction Exercises
Practice what you’ve learned in the Introduction chapter. These exercises cover containers, Docker vs VMs, the Docker ecosystem, and OCI standards.
Exercise 1 — Container vs VM Decision
Scenario: You need to deploy the following workloads. For each, decide whether you’d use a container or a VM, and explain why.
- A Python Flask API that needs to scale to 50 instances
- A Windows Server running a legacy .NET Framework 4.5 app on a Linux host
- A Redis cache for local development
- A security-critical multi-tenant workload where each tenant must be fully isolated
- A CI/CD build agent that runs tests in a clean environment
Show Answer
- Container — Same OS, needs fast scaling, stateless API
- VM — Different OS kernel (Windows on Linux), requires full OS
- Container —
docker run redisis instant, disposable, perfect for dev - VM — Strong isolation needed, shared kernel is a risk for multi-tenant
- Container — Clean environment per build, fast startup, ephemeral
Exercise 2 — Identify Docker Components
Question: Match each description to the correct Docker component.
| # | Description | Component |
|---|---|---|
| 1 | Background service that manages containers | ? |
| 2 | Command-line tool you type docker run into |
? |
| 3 | Public registry with millions of images | ? |
| 4 | YAML-based tool for multi-container apps | ? |
| 5 | Next-generation image builder | ? |
Show Answer
- Docker Daemon (
dockerd) - Docker CLI (
docker) - Docker Hub
- Docker Compose
- BuildKit
Exercise 3 — Namespace Matching
Question: Match each Linux namespace to what it isolates.
| Namespace | Isolates |
|---|---|
| PID | ? |
| NET | ? |
| MNT | ? |
| UTS | ? |
Show Answer
| Namespace | Isolates |
|---|---|
| PID | Process IDs — container sees its own PID 1 |
| NET | Network interfaces, IP addresses, ports |
| MNT | Filesystem mount points |
| UTS | Hostname |
Exercise 4 — OCI Standards
Question: Answer the following about OCI standards.
- What does OCI stand for?
- Name the three OCI specifications.
- Why were OCI standards created?
- What is
runc?
Show Answer
- Open Container Initiative
- Image Spec, Runtime Spec, Distribution Spec
- To prevent vendor lock-in and ensure portability — images built with Docker work with Podman, Kubernetes, etc.
runcis the reference implementation of the OCI Runtime Specification — it’s the tool that actually creates and runs containers using Linux kernel features.
Exercise 5 — True or False
- A container runs its own OS kernel.
- Docker was the first container technology ever created.
- Containers typically start in milliseconds to seconds.
- A VM can run a different OS than the host.
- OCI standards ensure Docker images only work with Docker.
Show Answer
- False — Containers share the host kernel
- False — chroot (1979), FreeBSD Jails (2000), Solaris Zones (2004), LXC (2008) came before Docker (2013)
- True — No OS boot required
- True — VMs run their own kernel via hypervisor
- False — OCI ensures images work with ANY compliant runtime (Docker, Podman, containerd)