Docker Interview Questions & Production Incident Runbooks (2026 Edition)
⚡ 159 Live Scenarios
🎯 STAR Method Answers📋 60s Elevator Pitches
Mastering docker interview questions requires a deep understanding of host-level kernel subsystems that extend far beyond simple Dockerfile authoring. When interviewing for senior platform and infrastructure roles, candidates are routinely tested on Linux kernel namespaces (PID, mount, network, IPC, user), cgroups v2 resource quotas, and overlay2 storage driver mechanics under extreme disk I/O loads. Interviewers will press you to diagnose subtle production container defects: mysterious zombie process accumulation resulting from improper init process PID 1 handling, phantom container restarts caused by hidden memory fragmentation, and bloated image layers introducing critical CVE vulnerabilities. Our Docker scenario interview questions train you to dissect multi-stage build caching strategies with BuildKit, enforce non-root user execution privileges, secure container daemon sockets, and optimize container networking bridges. Master these battle-tested terminal recipes, runtime inspection commands, and container security controls to confidently ace system design and live terminal debugging challenges across diverse production environments.
Interactive challenge: rearrange Dockerfile layers in real time, test BuildKit cache mounts, fix cache bust bugs, and achieve 90% build time reductions.
Get 1 Docker & Containers interview question in your inbox every week
Preparing for a cloud or platform interview? Subscribe to get our weekly deep-dive scenario plus instant access to the Top 50 Kubernetes Interview Questions & Incident Runbooks PDF.
docker logs — read why it exited. Use docker run -it sh to start interactively. Check the entrypoint/cmd. Common cause: the main process exits (e.g., a script r...
By default, containers are isolated. They need to be on the same Docker network. Create a network: docker network create app-net. Run both containers with --net...
Multi-stage build (build artifact in fat builder image, copy only artifact to slim runtime). Use alpine-based images. Clean up package manager cache in the same...
Same pod: share network namespace → communicate via localhost. Different pods: need a Kubernetes Service. Direct pod IP works but is ephemeral (changes on resta...
To limit container CPU without restarting it, run docker update --cpus 0.5 [container]. The daemon rewrites the container's cgroup CPU quota live, so the p...
COPY: copies files from build context to image. Simple and explicit. ADD: same as COPY but also supports URLs and auto-extracts tar archives. Prefer COPY — ADD&...
To share data between the host and a container, mount it: use a bind mount (-v /host/path:/container/path) to expose a specific host directory, or a named volum...
Docker Compose. Define all services in docker-compose.yml. docker-compose up starts everything. Auto-creates networks, manages startup order with depends_on, ha...
The container's PID 1 (init process) is still running but the app process (a child) crashed. If using shell scripts as entrypoint, the shell is still alive...
To inspect a running container, use docker inspect for the configuration Docker recorded (env, mounts, ports, limits) and docker exec or /proc/[pid]/environ for...
A build failing on apt-get update is usually a network or repository problem, not an apt bug: DNS or proxy settings inside the build, an end-of-life release who...
Multiple FROM statements in one Dockerfile. Build artifacts in a heavy build stage, copy only what's needed to a slim runtime stage. Final image contains n...
Mount a volume and use a log shipper sidecar to read and forward the file. Or configure the app to write to stdout. Containers should write to stdout/stderr — D...
trivy image — scans OS packages and app libraries for CVEs. Integrate in CI: fail the pipeline on HIGH/CRITICAL findings. Also: docker scout cves (Docker's...
A .dockerignore file lists paths that Docker leaves out of the build context, so they are never sent to the builder and cannot be copied into the image by COPY ...
EXPOSE in a Dockerfile records which port the container is expected to listen on as image metadata; it does not open or publish that port to the host. Publishin...
Docker Compose is not recommended for production at scale. For production: Kubernetes (EKS/GKE/AKS), ECS, or Docker Swarm (simpler than K8s). Compose is for loc...
To override the default CMD when running a container, put the new command after the image name: docker run my-app:1.0 python manage.py migrate. Whatever follows...
docker run --init runs a tiny init process (tini) as PID 1. This properly handles zombie process reaping and signal forwarding. Without init, if PID 1 doesn...
Override the entrypoint to sleep: docker run --entrypoint sleep myimage 300. Then exec in and investigate. Or: docker run --entrypoint /bin/sh -it myimage to ge...
Docker reuses unchanged layers from cache. Layers that change early in the Dockerfile invalidate all subsequent layers. Put slow-changing layers (base image, de...
DCT allows image publishers to sign images and consumers to verify signatures. DOCKER_CONTENT_TRUST=1 enforces that only signed images can be pulled/run. Preven...
To set resource limits for a Docker Compose service, add deploy.resources.limits with cpus and memory to the service in compose.yaml. Docker Compose v2 applies ...
Container networking at the Linux kernel level is built from a few primitives: each container gets its own network namespace, a veth pair connects it to a Linux...
To rebuild only a specific service in Docker Compose, name the service: docker compose up -d --build --no-deps web rebuilds the image for web and recreates just...
up starts all services defined in the compose file as long-running services. run runs a one-off command in a service container: docker-compose run app pytest. U...
Mounting the Docker socket (/var/run/docker.sock) gives the container full control over the Docker daemon — effectively root on the host. Extremely dangerous....
To roll back to a previous Docker image version in Kubernetes, run kubectl rollout undo deployment/my-app (optionally with --to-revision=N), or redeploy the kno...
Docker Swarm is Docker Engine's built-in clustering and orchestration mode: you join several hosts into one swarm, declare services, and Swarm schedules, l...
Use BuildKit's --build-context to pass multiple directories as build context. Use cache mounts for shared dependencies. Or extract shared code to a private...
docker run --restart=unless-stopped — restarts always except when manually stopped. Or --restart=always. Docker Compose: restart: unless-stopped in the service ...
Creates a new image from a running container's current state. Rarely used in production (not reproducible). Use it for: quick debugging snapshots. Never fo...
ARG VERSION=latest in Dockerfile. Build: docker build --build-arg VERSION=1.2.3 .. ARG values are available only at build time, not at runtime (use ENV for runt...
ECR lifecycle policies: keep only last N images, delete untagged images after X days. aws ecr put-lifecycle-policy --lifecycle-policy-text file://policy.json. F...
docker save writes one or more images, with all layers, tags and history, into a tar archive, and docker load reads that archive back into the local image store...
docker history — shows each layer, its size, and the command that created it. Use --no-trunc to see full commands. dive for interactive layer explorer....
VOLUME /data in Dockerfile tells Docker this path should be a volume. Docker auto-creates an anonymous volume at that path if none is provided. Runtime -v expli...
Docker Compose in CI (all services started via compose). Or CI service containers (GitHub Actions services, GitLab CI services). Or testcontainers — a library t...
docker network inspect — see which containers are on the network. From one container: ping (if on same user-defined network). nslookup to verify DNS. curl http:...
If they bind-mounted a *single file* (e.g., -v /path/to/app.py:/app/app.py) instead of a directory, the issue is how modern text editors (like Vim or some IDEs)...
You cannot exec a shell if the shell binary literally doesn't exist inside the container. You must inject tools from the outside using Linux namespaces....
Containers do not automatically inherit the ulimit settings from the user space of the host operating system. The Docker daemon manages its own default limits f...
Docker Desktop on Windows heavily masks the truth. To run Linux containers, it actually boots a hidden Linux VM deeply in the background (via WSL2 or Hyper-V). ...
By default, every Docker container gets its own isolated PID namespace, meaning each container can only see its own processes (its PID 1 and descendants)....
The container is likely running out of inodes, not disk space. The overlay2 filesystem has a finite number of inodes, and millions of small files can exhaust th...
Docker stores credentials per registry in ~/.docker/config.json, and you do NOT need to log out of one registry to use another. Each docker login adds a separat...
Docker containers on user-defined networks use Docker's embedded DNS server (127.0.0.11). On the default bridge network, containers inherit the host's...
Use Rootless Docker, which runs the Docker daemon and all containers entirely within a user's namespace without requiring root privileges on the host....
Use the --target flag to build only up to the test stage, and structure the Dockerfile so the test report is generated *before* the assertion that causes the bu...
Docker's default json-file logging driver stores container stdout/stderr as JSON files under /var/lib/docker/containers//. Without limits, these files grow...
Before executing any Dockerfile instruction, Docker packages the entire build context (the directory passed to docker build) and transfers it to the Docker daem...
Inside a container, localhost refers to the container's own loopback interface, not the host's. The container and host have separate network namespace...
Docker Hub enforces pull rate limits: anonymous users get 100 pulls per 6 hours per IP, authenticated free users get 200. CI servers sharing a single public IP ...
When Docker sends SIGTERM via docker stop, it delivers the signal to PID 1 inside the container. If PID 1 is a shell script (/bin/sh or /bin/bash), the shell do...
How to architect and operate Docker workloads across multiple clouds (AWS, Azure, GCP): multi-architecture image builds (buildx), centralized artifact registrie...
Layered observability architecture for container performance in production: diagnosing cgroup CPU throttling, memory working sets, cAdvisor and Prometheus metri...
How to write a production-ready, highly secure multi-stage Dockerfile during a live screen-sharing interview: separate dependency caching, compilation, unprivil...
Business and architectural value realization of Docker in production: transitioning from brittle snowflake servers to immutable container artifacts, eliminating...
Comprehensive container image security and repository governance: automated CI vulnerability scanning with Trivy, image signing via Cosign, AWS ECR scan-on-push...
A Docker container is reported as Up and running, but external HTTP requests fail with Connection Refused or Timeout. Diagnosing port mappings, 0.0.0.0 vs 127.0...
Diagnose and resolve containerd CRI socket freezes (`/run/containerd/containerd.sock`), client timeouts in kubelet, and distinguish between low-level `ctr` vs K...
Configure and tune Linux cgroups v2 memory controllers for containers. Understand the operational mechanics of `memory.high` proactive throttling versus `memory...
Deploy, configure, and secure Rootless Docker and containerd daemons. Understand user namespaces (`userns`), UID/GID sub-allocations, rootless networking with s...
Eliminate CVE attack surfaces by migrating application containers from Ubuntu/Debian/Alpine to Google Distroless and Scratch. Handle glibc/musl linking, TLS cer...
Implement hypervisor-level and kernel-proxy container sandboxing using gVisor (`runsc`) and Kata Containers (QEMU/Cloud-Hypervisor) to safely run untrusted mult...
Understand how the Linux kernel treats PID 1 in containers, why orphan child processes become defunct zombies (`Z` state), and how to configure Tini to ensure c...
Analyze the security and architectural trade-offs between Docker-in-Docker (`docker:dind` in privileged mode) and Docker-outside-of-Docker (`/var/run/docker.soc...
Triage and fix 'No space left on device' errors caused by OverlayFS inode exhaustion (100% IFree exhausted) despite ample disk gigabytes. Understand l...
Understand Docker Swarm's Ingress Routing Mesh, IPVS load balancing, source IP preservation, and how to bypass the routing mesh using host-mode port publis...
Master node-level container debugging using `crictl`, `nerdctl`, and `ctr`. Troubleshoot Pod sandboxes, pull images directly into the `k8s.io` namespace, and in...
Configure daemon-wide user namespace remapping (`userns-remap`) in Docker. Protect multi-tenant hosts by automatically mapping container root (UID 0) to unprivi...
Achieve sub-second container cold starts by implementing eStargz (Extended Stargz) lazy image pulling in containerd. Understand why containers only need 10% of ...
Diagnose and resolve the critical vulnerability where Docker bypasses host UFW/firewalld rules by inserting raw iptables PREROUTING rules. Configure the `DOCKER...
Implement bulletproof graceful termination in containerized applications. Diagnose shell-form vs exec-form ENTRYPOINT signal masking, bash trap handlers, and HT...
Configure Linux kernel Out-Of-Memory Killer scoring (`oom_score_adj`) to safeguard the Docker daemon, containerd, and kubelet from being killed during extreme h...
Deconstruct the containerd `shim-v2` architecture. Understand why a shim exists per container/pod sandbox, how it decouples runc execution, and how to triage or...
Configure and tune Linux kernel sysctl parameters within Docker containers. Distinguish between safe namespaced sysctls (network/IPC) and dangerous node-level s...
Configure and calculate Docker container memory ceilings: `--memory`, `--memory-swap`, and `--memory-swappiness`. Prevent severe disk thrashing caused by excess...
Implement principle of least privilege using Linux capabilities in Docker. Drop default capabilities (`--cap-drop=ALL`) and selectively restore only required ca...
Configure Docker Content Trust (DCT) to enforce digital signing and cryptographic verification of container images. Prevent deployment of untrusted or tampered ...
Master the command-line mapping between standard Docker CLI commands and containerd debugging utilities: `crictl` for Kubernetes, `nerdctl` for Docker parity, a...
Configure host Linux kernels and Docker containers to reliably generate core dumps during segmentation faults (`SIGSEGV`). Configure `/proc/sys/kernel/core_patt...
Diagnose and resolve containers that cannot be stopped or killed with `docker rm -f` or `kill -9` because processes are trapped in Linux kernel Uninterruptible ...
Achieve kernel-level observability into Docker containers without injecting code or restarting processes. Use eBPF and `bpftrace` to trace container filesystem ...
Master Docker build cache mechanics. Structure Dockerfile instructions in optimal order from lowest to highest frequency of change, separating dependency manife...
Maximize Docker Desktop performance on Apple Silicon (M1/M2/M3/M4). Configure VirtioFS file sharing, Apple Virtualization framework, Rosetta 2 x86 emulation, an...
Conduct a root cause investigation for runaway disk space exhaustion in `/var/lib/docker`. Triage unlinked open file descriptors holding disk space (`lsof +L1`)...
Deep dive into docker run internals: learn how the Docker CLI, containerd daemon, runc OCI runtime, Linux namespaces, cgroups v2, and overlay2 filesystem isolat...
Review core architectural concepts and high-frequency interview questions asked during senior Docker & Containers and SRE hiring loops. These direct answers cover production scenarios, incident runbooks, and candidate storytelling talking points.
A container exits immediately after starting. How do you debug it?
"When containerizing our microservices stack, container lifecycle and resource management were critical. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix."
Key Architectural Takeaway: Pro-Tip: docker logs — read why it exited. Use docker run -it sh to start interactively. Check the entrypoint/cmd. Common cause: the main.
Your Docker build fails with "no space left on device" on the CI server. What do you do?
"In an interview, I explain how we diagnosed container runtime failures without guessing. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix."
A containerized app can't connect to a database container on the same Docker host. What's wrong?
"During an image optimization initiative across our services, we solved this exact problem. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix."
Key Architectural Takeaway: Pro-Tip: By default, containers are isolated. They need to be on the same Docker network. Create a network: docker network create app-net. .
Your Docker image is 2GB. How do you reduce it?
"Container stability relies on clean signal handling (SIGTERM vs SIGKILL) and immutable image tagging. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix."
Key Architectural Takeaway: Pro-Tip: Multi-stage build (build artifact in fat builder image, copy only artifact to slim runtime). Use alpine-based images. Clean up pac.
How do containers in the same pod (Kubernetes) communicate vs containers in different pods?
"When containerizing our microservices stack, container lifecycle and resource management were critical. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix."
Key Architectural Takeaway: Pro-Tip: Same pod: share network namespace → communicate via localhost. Different pods: need a Kubernetes Service. Direct pod IP works but .
🌐
Explore Related DevOps & Cloud Domains
Cross-train across interconnected systems for senior and staff infrastructure rounds.
Master Docker & Containers & Platform Engineering In Production
Preparing for a cloud or platform interview? Subscribe to get our weekly deep-dive scenario plus instant access to the Top 50 Kubernetes Interview Questions & Incident Runbooks PDF.