Active Nerds
Docker Learning Stream

Docker Roadmap Articles & Question Stream

Browse questions, read quick answers, or expand full article breakdowns on demand. Filter by level, domain, or completion status using the sidebar dashboard.

Showing 54 of 54 questions
beginnerArchitecture12 min+10 XP

Containers vs. VMs: What the Kernel Actually Isolates

Question

A junior engineer says "a container is just a lightweight VM." Explain precisely why this analogy is wrong, and describe what a container actually *is* at the process level on the host.

beginnerImage Engineering14 min+10 XP

Images, layers, and the Dockerfile instruction order that matters

Question

You run `docker build` twice on the same Dockerfile with no changes and notice the second build finishes in under a second. Explain what mechanism makes this possible and what is actually being reused.

beginnerImage Engineering3 min+10 XP

Docker Layer Caching: Why Unchanged Rebuilds Finish Instantly

Question

You run `docker build` twice on the same Dockerfile with no changes and notice the second build finishes in under a second. Explain what mechanism makes this possible and what is actually being reused.

beginnerArchitecture4 min+10 XP

Containers vs. VMs: Why the Lightweight VM Analogy Is Wrong

Question

A junior engineer says "a container is just a lightweight VM." Explain precisely why this analogy is wrong, and describe what a container actually *is* at the process level on the host.

beginnerArchitecture20 min+15 XP

docker run, build, exec — the three commands you'll use daily

Question

A junior engineer says "a container is just a lightweight VM." Explain precisely why this analogy is wrong, and describe what a container actually *is* at the process level on the host.

beginnerArchitecture4 min+10 XP

Containers vs. VMs: Why 'Lightweight VM' Is the Wrong Mental Model

Question

A junior engineer says "a container is just a lightweight VM." Explain precisely why this analogy is wrong, and describe what a container actually *is* at the process level on the host.

beginnerImage Engineering4 min+10 XP

Docker Layer Caching: Why Unchanged Builds Finish Instantly

Question

You run `docker build` twice on the same Dockerfile with no changes and notice the second build finishes in under a second. Explain what mechanism makes this possible and what is actually being reused.

beginnerImage Engineering4 min+10 XP

ENTRYPOINT vs. CMD: Why Removing CMD Changes Runtime Behavior

Question

Your team's Dockerfile uses both `ENTRYPOINT` and `CMD`. A teammate wants to remove `CMD` because "it seems redundant." Explain why removing it would change the container's runtime behavior and give a scenario where this distinction matters operationally.

beginnerPersistence5 min+10 XP

Bind Mounts vs. COPY: Why Dev Convenience Doesn't Belong in Production

Question

A developer mounts their local project folder into a container with `-v` during development, but in the production Dockerfile they use `COPY`. Explain why these two approaches exist and why you would never rely on a bind mount in a production deployment.

beginnerPersistence4 min+10 XP

Container Filesystem Lifecycle: Why Data Disappears Without Volumes

Question

A container running a database is removed with `docker rm`, and the team is shocked their data disappeared. Diagnose what likely went wrong in their setup and explain the container filesystem lifecycle that caused this.

beginnerNetworking4 min+10 XP

Docker Port Mapping: How a Packet Reaches Your Container

Question

A service inside a container listens on port 8080, and it's exposed with `-p 80:8080`. Walk through what actually happens to a packet arriving at the host's port 80 to reach the process inside the container.

beginnerImage Engineering5 min+10 XP

Alpine vs. Ubuntu Base Images: Trade-offs Beyond Image Size

Question

Two engineers build the same application — one from `ubuntu:latest`, another from `alpine`. Beyond image size, what practical engineering trade-offs should inform this base image decision?

beginnerOperations4 min+10 XP

Docker Logging Model: Why stdout/stderr, Not Log Files

Question

A teammate adds application logging to a file inside the container instead of stdout/stderr, then complains `docker logs` shows nothing. Explain the underlying logging model Docker expects and why their approach breaks it.

advancedArchitecture9 min+20 XP

Linux Namespaces: The Isolation Mechanisms Behind Every Container

Question

Explain, namespace by namespace (PID, NET, MNT, UTS, IPC, USER), what specific kernel isolation each one provides to a container, and describe a real scenario where sharing one particular namespace between containers (e.g., `--pid=container:x`) is a deliberate and useful debugging technique.

advancedOperations9 min+20 XP

cgroups Memory Accounting: Why OOM-Kills Happen Below the Limit

Question

A container set with `--memory=512m` gets OOM-killed even though `docker stats` shows it using only 300MB of RSS at the time. Explain what other memory accounting cgroups tracks (page cache, kernel memory) that could explain this, and how you'd investigate.

beginnerImage Engineering4 min+10 XP

Docker Build Context: Why an Untouched node_modules Folder Slows Builds

Question

A build suddenly takes much longer after a teammate added a large `node_modules` folder to the project directory, even though it's never referenced in the Dockerfile. Explain what's happening and how to fix it.

advancedImage Engineering8 min+20 XP

OverlayFS Copy-Up: The Hidden Cost of Small-File Writes in Containers

Question

A build suddenly takes much longer after a teammate added a large `node_modules` folder to the project directory, even though it's never referenced in the Dockerfile. Explain what's happening and how to fix it.

advancedArchitecture8 min+20 XP

From docker run to runc: Tracing the Full Container Startup Chain

Question

Diagram (in words) the full process chain from a `docker run` invocation down to the actual container process, explicitly naming the role of `dockerd`, `containerd`, `containerd-shim`, and `runc`, and explain why the shim's existence allows the Docker daemon to be restarted without killing running containers.

advancedSecurity8 min+20 XP

Linux Capabilities: The Least-Privilege Alternative to --privileged

Question

A container needs to bind to a privileged port and adjust system time as part of its function, but your security policy forbids `--privileged`. Explain the capability-based alternative, name the specific capabilities required, and articulate why granular capability grants are architecturally superior to the privileged flag.

beginnerOperations4 min+10 XP

Environment Variables in Docker: Configuring One Image for Many Environments

Question

Your application needs different database URLs in staging versus production, but you want to use the exact same image in both. Explain the mechanism that makes this possible without rebuilding the image, and why baking config into the image is considered an anti-pattern.

advancedOperations9 min+20 XP

Rootless Docker: How User Namespace Remapping Blocks Host Root Escalation

Question

Your application needs different database URLs in staging versus production, but you want to use the exact same image in both. Explain the mechanism that makes this possible without rebuilding the image, and why baking config into the image is considered an anti-pattern.

advancedNetworking9 min+20 XP

Docker Networking Internals: How Custom Bridges Rewrite iptables NAT and FILTER Rules

Question

You create a custom bridge network and notice new `iptables` chains and rules appear on the host without you touching `iptables` directly. Explain what Docker is doing to the NAT and FILTER tables to make inter-container and container-to-external routing work, and describe a scenario where a conflicting host firewall rule could silently break container connectivity.

advancedNetworking9 min+20 XP

VXLAN Overlay Networks: How Multi-Host Containers Communicate by IP

Question

In a multi-host overlay network (e.g., Swarm), two containers on different physical hosts communicate directly by container IP. Explain the encapsulation mechanism (VXLAN) that makes this possible at the packet level, and identify the MTU-related failure mode this commonly introduces.

beginnerArchitecture4 min+10 XP

Container Lifecycle and PID 1: Why Containers Exit When Their Main Process Stops

Question

A container running a simple shell script exits immediately after starting, even though the script "runs forever" when tested locally. What container lifecycle rule explains this behavior?

advancedArchitecture8 min+20 XP

OCI Image Manifest vs. Runtime Spec: From Pulled Image to Running Container

Question

A container running a simple shell script exits immediately after starting, even though the script "runs forever" when tested locally. What container lifecycle rule explains this behavior?

advancedOperations9 min+20 XP

CFS CPU Throttling: Why --cpus=2 Causes Latency Spikes Under 200% Usage

Question

A service configured with `--cpus=2` shows periodic latency spikes even though average CPU usage sits well under 200%. Explain how CFS (Completely Fair Scheduler) quota-based throttling within a fixed period can cause this, and why average utilization metrics can be misleading here.

advancedSecurity8 min+20 XP

--pid=host: The Process Isolation Guarantee It Breaks — and When That's Justified

Question

A container running as an unprivileged process is still able to see and signal processes on the host when run with `--pid=host`. Explain precisely what isolation guarantee is being intentionally broken, and describe one legitimate production use case where this trade-off is justified.

beginnerImage Engineering4 min+10 XP

Docker Image Tagging: Why the latest Tag Breaks Reproducible Deployments

Question

Your team deploys using the `latest` tag and occasionally ends up with different code running on different hosts despite "not changing anything." Explain why tag-based deployment without immutable references is risky in production.

advancedImage Engineering9 min+20 XP

overlay2 vs. devicemapper/btrfs: Storage Driver Trade-offs at Container Density Scale

Question

Your team deploys using the `latest` tag and occasionally ends up with different code running on different hosts despite "not changing anything." Explain why tag-based deployment without immutable references is risky in production.

expertSecurity12 min+25 XP

seccomp Syscall Filtering: Diagnosing a Blocked clone() in a Hardened Profile

Question

A hardened production seccomp profile blocks an application from calling `clone()` with certain flags, causing an obscure runtime crash unrelated to any obvious security feature. Explain how seccomp filters operate at the syscall level, why default Docker seccomp profiles allow most syscalls but block dangerous ones, and how you'd methodically identify which specific syscall is being blocked.

expertSecurity11 min+25 XP

AppArmor vs. seccomp: Mandatory Access Control Beyond Syscall Filtering

Question

Contrast what AppArmor's mandatory access control profile enforces versus what seccomp enforces for the same container, and describe a concrete attack scenario that seccomp alone would not stop but a correctly scoped AppArmor profile would.

intermediateImage Engineering6 min+15 XP

Multi-Stage Docker Builds: Shrinking Go Images by Discarding the Compiler Toolchain

Question

Your Go application's final image is 900MB because it includes the full compiler toolchain. Design a multi-stage build that resolves this, and explain precisely what gets carried between stages and what gets discarded.

expertImage Engineering11 min+25 XP

oom_score_adj and PID 1: Why the OOM Killer Targets the Wrong Process

Question

Your Go application's final image is 900MB because it includes the full compiler toolchain. Design a multi-stage build that resolves this, and explain precisely what gets carried between stages and what gets discarded.

expertImage Engineering12 min+25 XP

cgroup OOM Killing: Why the Kernel Kills the Wrong Process in Your Container

Question

Your Go application's final image is 900MB because it includes the full compiler toolchain. Design a multi-stage build that resolves this, and explain precisely what gets carried between stages and what gets discarded.

expertArchitecture11 min+25 XP

live-restore: Zero-Downtime Docker Engine Upgrades and Their Limits

Question

You need to perform a zero-downtime Docker Engine upgrade on a host running stateful production containers. Explain how `live-restore` allows containers to keep running through a daemon restart, what it does *not* protect against, and what happens if the containerd/shim architecture itself needs an upgrade at the same time.

expertOperations12 min+25 XP

Debugging Distroless Containers: Two Real Techniques Without a Shell

Question

A production incident requires live debugging of a distroless container that has no shell, no package manager, and no coreutils. Walk through at least two distinct real-world techniques (e.g., ephemeral debug containers sharing namespaces, sidecar attach) to inspect its running process, filesystem, and network state without modifying the original image.

intermediateImage Engineering5 min+15 XP

Docker Layer Caching: Why COPY Order Determines Build Speed

Question

A Dockerfile does `COPY . .` before `RUN npm install`. Every single code change forces a full dependency reinstall during CI, adding 4 minutes per build. Explain the caching mechanic causing this and restructure the instructions to fix it.

expertImage Engineering13 min+25 XP

Hardening an Internet-Facing Container: A Layer-by-Layer Runtime Profile

Question

A Dockerfile does `COPY . .` before `RUN npm install`. Every single code change forces a full dependency reinstall during CI, adding 4 minutes per build. Explain the caching mechanic causing this and restructure the instructions to fix it.

expertNetworking12 min+25 XP

conntrack Table Exhaustion: Why Docker's NAT-Based Networking Drops Connections Under Load

Question

A high-throughput edge service running in containers starts silently dropping new connections under load, and dmesg shows conntrack table full errors. Explain how Docker's iptables-based NAT interacts with the kernel's connection tracking table, why containerized workloads are especially prone to exhausting it, and the tuning levers available.

Quick Answer

Every connection that passes through Docker's iptables-based NAT (container port publishing, outbound masquerading) must be tracked by the kernel's conntrack table so return traffic can be correctly un-NAT'd, and that table has a fixed maximum size — once full, the kernel starts silently dropping new connection attempts rather than degrading gracefully, which is exactly what a dmesg "conntrack table full" error indicates.

Detailed Answer

NAT isn't stateless. When Docker's POSTROUTING/MASQUERADE rule rewrites a container's outbound source IP, or a PREROUTING/DNAT rule rewrites an inbound published-port destination, the kernel has to remember that mapping somewhere — otherwise return packets would have no way to be translated back to the original address. That memory is the connection tracking table (nf_conntrack), a hash table where the kernel records one entry per active connection (roughly: source IP/port, destination IP/port, protocol, and NAT translation state), consulted on every packet that touches a conntrack-aware iptables rule.

The table has a hard ceiling, net.netfilter.nf_conntrack_max (commonly defaulting to 65536 or 262144 depending on distro/kernel, often scaled by available RAM at boot). Once the number of tracked connections hits that ceiling, the kernel cannot create new conntrack entries — and because Docker's NAT rules depend on conntrack to function, packets that would need a new entry (new connections) get dropped, logged as nf_conntrack: table full, dropping packet in dmesg. Critically, existing connections already in the table keep working; only new connection attempts fail, which is exactly the "silently dropping new connections under load" symptom — the service looks alive and even handles existing traffic, but can't accept anything new.

Loading diagram...

Why Containerized Workloads Are Especially Prone to This

  • Every container's traffic goes through NAT by default. Unlike a bare-metal service binding directly to a host interface, a containerized service almost always has its traffic passing through at least one Docker-managed NAT rule (published ports, outbound masquerading, or both), so conntrack entries accumulate at a rate proportional to all container connection churn on the host, not just one service's.
  • High connection churn workloads multiply entries fast. Edge/proxy services handling many short-lived connections (HTTP/1.1 without keep-alive, high-frequency polling clients, connection-per-request patterns) create and tear down conntrack entries constantly — and entries aren't removed the instant a connection closes; they linger for a timeout period (nf_conntrack_tcp_timeout_* values, some defaulting to hours for established connections), so churn plus lingering timeouts compounds table occupancy faster than raw concurrent-connection counts would suggest.
  • Multiple containers share one host-wide table. nf_conntrack_max is a single, host-level ceiling — it isn't namespaced per container or partitioned per network. A busy neighbor container's connection load counts against the exact same shared budget as the edge service that's actually struggling, meaning the table can fill from aggregate host activity even when any single service's own load looks reasonable.
  • Overlay/VXLAN encapsulation adds its own tracked flows. In multi-host Swarm setups, the VXLAN tunnel traffic between hosts is itself often subject to conntrack tracking at the outer-packet level, adding to table pressure beyond just the inner container-to-container connections.

Tuning Levers

  • Raise net.netfilter.nf_conntrack_max (sysctl -w net.netfilter.nf_conntrack_max=1048576 or higher, persisted in /etc/sysctl.conf) — the most direct fix, sized to the host's actual peak concurrent+lingering connection count with headroom, not just current averages.
  • Reduce lingering timeouts for high-churn protocolsnet.netfilter.nf_conntrack_tcp_timeout_established and related timeout sysctls can be tuned down from very conservative defaults so closed/idle connections free their table slot sooner, directly reducing table pressure from churn-heavy workloads.
  • Increase the conntrack hash table size (net.netfilter.nf_conntrack_buckets, often needs a module parameter or kernel boot parameter alongside the max) to keep lookups fast as the table grows — raising nf_conntrack_max without a proportionate bucket count increase can turn conntrack lookups into a CPU cost of their own.
  • Reduce actual NAT dependency where possible — using host networking mode (--network=host) for the specific high-throughput edge service removes it from Docker's NAT path entirely (at the cost of losing network namespace isolation), which is a legitimate trade-off specifically for this class of problem on a service that doesn't need port remapping.
  • Monitor proactively, not just react to dmesgconntrack -C (or cat /proc/sys/net/netfilter/nf_conntrack_count) against nf_conntrack_max as an ongoing metric catches the trend before it becomes a production drop event.
# Check current usage against the ceiling
cat /proc/sys/net/netfilter/nf_conntrack_count
cat /proc/sys/net/netfilter/nf_conntrack_max

# Raise the ceiling
sysctl -w net.netfilter.nf_conntrack_max=1048576

Key Takeaway

conntrack table exhaustion is a host-wide, shared-budget problem that Docker's NAT dependency makes containers especially prone to under connection churn, and it fails silently (dropped new connections, working existing ones) rather than with an obvious error — nf_conntrack_count vs. nf_conntrack_max should be a standing metric on any NAT-heavy container host.


expertOperations12 min+25 XP

PSI in cgroups v2: Finding the Real Bottleneck When Utilization Looks Fine

Question

Standard CPU/memory utilization metrics look healthy, but application-level latency at the edge is degrading under load. Explain how Pressure Stall Information (PSI) in cgroups v2 exposes resource contention that traditional utilization metrics miss, and how you'd use it to diagnose whether the bottleneck is CPU, memory, or I/O contention.

intermediateImage Engineering6 min+15 XP

BuildKit Cache Mounts: Persistent Dependency Caching Across Ephemeral CI Runners

Question

Even after reordering Dockerfile instructions for cache-friendliness, your team's CI runners (ephemeral, ban `--cache-from` layer reuse) still reinstall dependencies every run. What BuildKit feature addresses this specific problem, and how does it differ from ordinary layer caching?

expertImage Engineering11 min+25 XP

no-new-privileges: Why Capability Dropping Alone Doesn't Stop setuid Escalation

Question

Even after reordering Dockerfile instructions for cache-friendliness, your team's CI runners (ephemeral, ban `--cache-from` layer reuse) still reinstall dependencies every run. What BuildKit feature addresses this specific problem, and how does it differ from ordinary layer caching?

expertArchitecture13 min+25 XP

Inside a runc Breakout CVE: How /proc/self/exe Overwrite Attacks Worked

Question

Explain, at a mechanistic level, how a historical runc container-breakout vulnerability (such as the `/proc/self/exe` file-descriptor overwrite class of CVEs) allowed a malicious container to overwrite the host `runc` binary, and what defense-in-depth layers (user namespaces, read-only host binaries, monitoring) would have limited the blast radius even if the specific CVE were unpatched.

expertOperations11 min+25 XP

PID 1 and SIGTERM: Why Containers Get Hard-Killed Despite Correct Signal Handling

Question

During a rolling deployment, containers are hard-killed after a 10-second timeout, dropping in-flight requests, even though the application has SIGTERM handling implemented correctly. Diagnose the most likely architectural cause involving PID 1, process supervision, and signal propagation inside the container, and describe the fix.

intermediateNetworking5 min+15 XP

Default Bridge vs. User-Defined Bridge: Why Container Name Resolution Differs

Question

Two containers on the default `bridge` network can't resolve each other by container name, but two containers on a user-defined bridge network can. Explain the underlying difference in how Docker handles DNS resolution between these two network types.

expertNetworking13 min+25 XP

Image Supply Chain Security: Signing, Verification, and Admission Control at Deploy Time

Question

Two containers on the default `bridge` network can't resolve each other by container name, but two containers on a user-defined bridge network can. Explain the underlying difference in how Docker handles DNS resolution between these two network types.

intermediateNetworking6 min+15 XP

Host Networking vs. Bridge Networking: The Latency Trade-Off Behind --network host

Question

A latency-sensitive service performs noticeably better under `--network host` than the default bridge network. Explain the actual network path difference that causes this performance gap, and identify the operational trade-off the team is accepting by using host networking.

intermediateArchitecture5 min+15 XP

depends_on in Docker Compose: Why Container Startup Order Isn't Application Readiness

Question

A `docker-compose.yml` uses `depends_on` to ensure the database container starts before the API container, but the API still crashes on startup trying to connect. Explain why `depends_on` alone doesn't solve this problem and what actually needs to happen.

intermediateSecurity6 min+15 XP

UID Mapping in Docker: Why Bind-Mounted Files End Up Owned by Root

Question

A container runs as root by default, and a file it writes to a bind-mounted volume ends up owned by `root` on the host, breaking the host user's ability to edit it. Explain the UID mapping reality behind this, and describe two distinct strategies to prevent it.

intermediateSecurity7 min+15 XP

Running Containers as Non-Root: Dockerfile Changes and the Trade-Offs They Introduce

Question

Your security team mandates that no production container may run as UID 0. Walk through what changes are required in the Dockerfile and what operational issues (port binding, file permissions, package installs) commonly break as a result — and how to resolve each.

intermediateNetworking6 min+15 XP

Docker's Embedded DNS Resolver: Why External Hostname Lookups Intermittently Fail Under Load

Question

A container intermittently fails to resolve an external hostname under load, though `curl` works fine most of the time. Explain how Docker's embedded DNS resolver works and a plausible root cause for intermittent resolution failures.

intermediateOperations6 min+15 XP

Docker Compose Health Checks: Reporting True Application Readiness, Not Just Process State

Question

A Compose stack reports all containers as "running," yet the application is non-functional because the API started before the database finished initializing. Design a `HEALTHCHECK`-based solution and explain how it changes container state reporting versus a plain process check.

intermediateImage Engineering5 min+15 XP

Docker Build Context Bloat: How .dockerignore Prevents Sending Unnecessary Files to the Daemon

Question

Your CI logs show the build context being sent to the daemon is 1.2GB despite a small application. Explain the mechanism by which this bloat occurs and how `.dockerignore` interacts with the build process to prevent it.

intermediatePersistence6 min+15 XP

Named Volumes Across Hosts: Why Local Volumes Don't Follow Rescheduled Containers

Question

A team migrating from a single Docker host to a small Swarm/multi-host setup discovers that named volumes don't "follow" a rescheduled container to another node. Explain why this happens and what class of solution is required.