supraj.dev

Interview questions & answers

Docker

Images, layers, networking, and container internals.

  • 141 questions
  • 5 easy
  • 64 medium
  • 72 hard
  • 1 related article

141 questions

Question 1Easy

What is the difference between an image and a container?

#
Show answer

An image is a read-only, layered template (the blueprint). A container is a running, writable instance created from an image — image + a thin writable layer + an isolated process namespace. You can run many containers from one image.

Question 2Easy

What is the difference between CMD and ENTRYPOINT?

#
Show answer

ENTRYPOINT sets the fixed executable that always runs; CMD provides default arguments that are easily overridden at docker run. Best practice: ENTRYPOINT for the binary, CMD for default flags. If you give both in exec form, CMD's values are appended as args to ENTRYPOINT.

Question 3Medium

How does Docker layer caching work and how do you optimize a Dockerfile for it?

#
Show answer

Each instruction creates a layer; Docker reuses cached layers until something changes — after which every later layer is rebuilt. So order from least- to most-frequently-changing: copy dependency manifests and install deps before copying source, so editing code doesn't invalidate the dependency layer. Combine related RUN commands, use .dockerignore, and prefer multi-stage builds to keep the final image small.

Question 4Medium

What is a multi-stage build and why use one?

#
Show answer

A Dockerfile with multiple FROM stages: you build/compile in a heavy stage (with compilers, dev deps) and COPY only the resulting artifacts into a minimal final stage (e.g. distroless or alpine). Result: much smaller, more secure runtime images with no build toolchain or source left behind.

Question 5Hard

How are containers isolated from each other and the host?

#
Show answer

Mainly via Linux kernel features: namespaces give each container its own view of PIDs, network, mounts, users, IPC, and hostname; cgroups limit and account CPU/memory/IO; capabilities drop privileged kernel operations; and seccomp/AppArmor/SELinux restrict syscalls. Containers share the host kernel — that's why isolation is weaker than a VM and why you run as non-root and drop capabilities.

Question 6Medium

A Node.js application running in a Docker container crashes with exit code 137 after a few hours. Docker logs show no application errors. What is the most likely cause and how do you verify and fix it?

#
Show answer

Exit code 137 = 128 + 9 (SIGKILL), meaning the kernel OOM-killed the container. Verify: docker inspect <container> --format '{{.State.OOMKilled}}' returns true; dmesg | grep -i oom shows the kill; docker stats <container> replay shows memory hitting the limit. Fix: increase --memory, set Node.js --max-old-space-size to leave GC headroom, check for memory leaks via heap snapshots (--inspect), or add --memory-reservation so Docker signals the app before the hard limit. Also verify swap: --memory-swap must be >= --memory or OOM kills happen sooner.

Question 7Hard

Explain the full flow of how Docker's overlay2 driver handles image layers and copy-on-write. What happens when you run docker commit on a running container?

#
Show answer

Overlay2 stacks layers: lowerdir (shared read-only image layers), upperdir (per-container writable layer), mergeddir (union via kernel overlayfs). Read: if file exists in upperdir return it, else search lowerdir top-to-bottom. Write (copy-up): modifying a file in lowerdir copies it to upperdir first, then modifies — expensive for large files. docker commit snapshots the upperdir into a new image layer: Docker tars the container's filesystem diff, compresses it, computes a sha256 digest, and creates a new layer stacked on the parent layers. The new layer is immutable. CoW performance trap: frequently writing to large files in base images causes repeated copy-up. Use volumes (bind mounts) for runtime data to bypass the CoW layer entirely.

Question 8Hard

You have Docker Compose with 5 services including Redis. Redis needs a config change without downtime. Walk through the sequence, data persistence, and health-check strategy.

#
Show answer

Docker Compose cannot natively do rolling updates on a single service. Strategy: (1) Deploy a redis-failover service with the new config alongside the old redis. (2) Update app configs (via env vars or config service) to point to redis-failover first. (3) Restart dependent services one at a time: docker compose up -d --no-deps web api worker. (4) Health checks: healthcheck: {test: ["CMD","redis-cli","ping"], interval:5s, retries:3, start_period:10s}. (5) Once all traffic routes to redis-failover, stop old redis: docker compose stop redis. (6) Rename redis-failover -> redis in compose file, docker compose up -d to align. For data persistence: run docker compose exec redis redis-cli SAVE before cutover to ensure the latest RDB is on a volume. The better long-term solution: use Redis Sentinel or a managed Redis (ElastiCache, Upstash) for real HA.

Question 9Hard

Docker incident: Docker builds jumped from 4 minutes to 35 minutes after a small source change. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker build --progress=plain, docker history, BuildKit cache logs, and layer size inspection. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Order Dockerfile layers from stable to volatile, copy lockfiles before source, use BuildKit cache mounts for package managers, keep secrets in --secret mounts, and push only minimal runtime images.

Question 10Hard

Docker architecture scenario: Your team needs fast, reproducible images for a monorepo with multiple services. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Order Dockerfile layers from stable to volatile, copy lockfiles before source, use BuildKit cache mounts for package managers, keep secrets in --secret mounts, and push only minimal runtime images.

Question 11Medium

Docker security scenario: Developers are copying secrets into images during build. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Order Dockerfile layers from stable to volatile, copy lockfiles before source, use BuildKit cache mounts for package managers, keep secrets in --secret mounts, and push only minimal runtime images.

Question 12Hard

Docker release scenario: You need to move services to multi-stage builds without breaking runtime behavior. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Order Dockerfile layers from stable to volatile, copy lockfiles before source, use BuildKit cache mounts for package managers, keep secrets in --secret mounts, and push only minimal runtime images.

Question 13Medium

Docker reliability/cost scenario: CI minutes and registry storage costs are rising every sprint. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Order Dockerfile layers from stable to volatile, copy lockfiles before source, use BuildKit cache mounts for package managers, keep secrets in --secret mounts, and push only minimal runtime images.

Question 14Hard

Docker incident: A container exits immediately in Kubernetes but works on a developer laptop. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker run --rm -it --entrypoint sh, docker inspect, container logs, and environment comparison. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use exec-form ENTRYPOINT, make required env explicit, run as a non-root UID, write only to declared writable paths, and test the exact production command in CI.

Question 15Hard

Docker architecture scenario: You need one image that runs consistently across local Docker, CI, and production. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use exec-form ENTRYPOINT, make required env explicit, run as a non-root UID, write only to declared writable paths, and test the exact production command in CI.

Question 16Medium

Docker security scenario: The image runs as root and writes to unexpected filesystem paths. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use exec-form ENTRYPOINT, make required env explicit, run as a non-root UID, write only to declared writable paths, and test the exact production command in CI.

Question 17Hard

Docker release scenario: You are changing the entrypoint and user for a production service. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use exec-form ENTRYPOINT, make required env explicit, run as a non-root UID, write only to declared writable paths, and test the exact production command in CI.

Question 18Medium

Docker reliability/cost scenario: Frequent crash loops are consuming on-call time. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use exec-form ENTRYPOINT, make required env explicit, run as a non-root UID, write only to declared writable paths, and test the exact production command in CI.

Question 19Hard

Docker incident: A Node or Python service image is over 2 GB and cold starts are slow. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker image ls, docker history --no-trunc, dive, and vulnerability scan output. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use multi-stage builds, copy only runtime artifacts, remove package caches, choose slim or distroless bases deliberately, and keep a separate debug image instead of bloating production images.

Question 20Hard

Docker architecture scenario: You need smaller images without losing debugging ability. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use multi-stage builds, copy only runtime artifacts, remove package caches, choose slim or distroless bases deliberately, and keep a separate debug image instead of bloating production images.

Question 21Medium

Docker security scenario: Build tools and package manager tokens remain in the final image. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use multi-stage builds, copy only runtime artifacts, remove package caches, choose slim or distroless bases deliberately, and keep a separate debug image instead of bloating production images.

Question 22Hard

Docker release scenario: You need to replace base images across many services. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use multi-stage builds, copy only runtime artifacts, remove package caches, choose slim or distroless bases deliberately, and keep a separate debug image instead of bloating production images.

Question 23Medium

Docker reliability/cost scenario: Registry transfer, deploy time, and vulnerability scan noise are high. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use multi-stage builds, copy only runtime artifacts, remove package caches, choose slim or distroless bases deliberately, and keep a separate debug image instead of bloating production images.

Question 24Hard

Docker incident: Two containers on the same host cannot connect even though exposed ports look correct. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker network inspect, docker port, ss -ltnp, container DNS checks, and curl from inside the network. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Distinguish container ports from published host ports, use user-defined networks for DNS, bind admin ports to localhost only, and avoid host networking unless there is a clear reason.

Question 25Hard

Docker architecture scenario: You need predictable service-to-service networking for local integration tests. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Distinguish container ports from published host ports, use user-defined networks for DNS, bind admin ports to localhost only, and avoid host networking unless there is a clear reason.

Question 26Medium

Docker security scenario: A container exposes internal admin ports to the host network. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Distinguish container ports from published host ports, use user-defined networks for DNS, bind admin ports to localhost only, and avoid host networking unless there is a clear reason.

Question 27Hard

Docker release scenario: You are moving from host networking to bridge or compose networks. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Distinguish container ports from published host ports, use user-defined networks for DNS, bind admin ports to localhost only, and avoid host networking unless there is a clear reason.

Question 28Medium

Docker reliability/cost scenario: Test flakiness is blocking releases. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Distinguish container ports from published host ports, use user-defined networks for DNS, bind admin ports to localhost only, and avoid host networking unless there is a clear reason.

Question 29Hard

Docker incident: Data disappears after recreating a database container. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker volume ls, docker volume inspect, mount inspection, and filesystem ownership checks. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use named volumes for managed persistence, bind mounts only when host-path coupling is intentional, set correct UID/GID ownership, and prune unused volumes through controlled cleanup jobs.

Question 30Hard

Docker architecture scenario: You need persistent local and staging state with clean teardown rules. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use named volumes for managed persistence, bind mounts only when host-path coupling is intentional, set correct UID/GID ownership, and prune unused volumes through controlled cleanup jobs.

Question 31Medium

Docker security scenario: Containers mount the host Docker socket or broad host paths. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use named volumes for managed persistence, bind mounts only when host-path coupling is intentional, set correct UID/GID ownership, and prune unused volumes through controlled cleanup jobs.

Question 32Hard

Docker release scenario: You are replacing bind mounts with named volumes. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use named volumes for managed persistence, bind mounts only when host-path coupling is intentional, set correct UID/GID ownership, and prune unused volumes through controlled cleanup jobs.

Question 33Medium

Docker reliability/cost scenario: Disk usage on CI runners keeps growing. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use named volumes for managed persistence, bind mounts only when host-path coupling is intentional, set correct UID/GID ownership, and prune unused volumes through controlled cleanup jobs.

Question 34Hard

Docker incident: Deploys fail with image pull errors only in production nodes. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker login, pull events, registry audit logs, node image pull errors, and credential helper config. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use short-lived tokens or workload identity where possible, scope pull permissions by repository, pre-warm critical images, and rotate credentials with overlapping validity.

Question 35Hard

Docker architecture scenario: You need private registry access across CI, staging, and production. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use short-lived tokens or workload identity where possible, scope pull permissions by repository, pre-warm critical images, and rotate credentials with overlapping validity.

Question 36Medium

Docker security scenario: Long-lived registry credentials are stored in plain text. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use short-lived tokens or workload identity where possible, scope pull permissions by repository, pre-warm critical images, and rotate credentials with overlapping validity.

Question 37Hard

Docker release scenario: You are rotating registry credentials without stopping deployments. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use short-lived tokens or workload identity where possible, scope pull permissions by repository, pre-warm critical images, and rotate credentials with overlapping validity.

Question 38Medium

Docker reliability/cost scenario: Image pulls are rate limited during autoscaling events. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use short-lived tokens or workload identity where possible, scope pull permissions by repository, pre-warm critical images, and rotate credentials with overlapping validity.

Question 39Hard

Docker incident: A container is running but the application is unavailable. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker inspect --format, health status, app logs, and direct health endpoint calls. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Separate liveness from readiness, make health checks cheap and deterministic, hide sensitive output, and align Docker health checks with orchestrator probes.

Question 40Hard

Docker architecture scenario: You need reliable health signals for orchestration. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Separate liveness from readiness, make health checks cheap and deterministic, hide sensitive output, and align Docker health checks with orchestrator probes.

Question 41Medium

Docker security scenario: Health endpoints expose sensitive dependency details. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Separate liveness from readiness, make health checks cheap and deterministic, hide sensitive output, and align Docker health checks with orchestrator probes.

Question 42Hard

Docker release scenario: You are adding health checks to existing images. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Separate liveness from readiness, make health checks cheap and deterministic, hide sensitive output, and align Docker health checks with orchestrator probes.

Question 43Medium

Docker reliability/cost scenario: Bad containers stay in service and cause user-facing errors. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Separate liveness from readiness, make health checks cheap and deterministic, hide sensitive output, and align Docker health checks with orchestrator probes.

Question 44Hard

Docker incident: A container is killed under load with exit code 137. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker stats, kernel OOM logs, cgroup metrics, and application heap profiles. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Set memory based on real peak plus headroom, tune runtime heap limits, avoid CPU throttling surprises, and alert on saturation before OOM kills happen.

Question 45Hard

Docker architecture scenario: You need predictable CPU and memory behavior on shared hosts. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Set memory based on real peak plus headroom, tune runtime heap limits, avoid CPU throttling surprises, and alert on saturation before OOM kills happen.

Question 46Medium

Docker security scenario: No limits allow noisy containers to starve critical workloads. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Set memory based on real peak plus headroom, tune runtime heap limits, avoid CPU throttling surprises, and alert on saturation before OOM kills happen.

Question 47Hard

Docker release scenario: You are introducing memory and CPU limits for existing services. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Set memory based on real peak plus headroom, tune runtime heap limits, avoid CPU throttling surprises, and alert on saturation before OOM kills happen.

Question 48Medium

Docker reliability/cost scenario: Host saturation causes multiple unrelated containers to degrade. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Set memory based on real peak plus headroom, tune runtime heap limits, avoid CPU throttling surprises, and alert on saturation before OOM kills happen.

Question 49Hard

Docker incident: Container logs fill the host disk overnight. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker system df, log driver config, /var/lib/docker/containers, and log pipeline metrics. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use log rotation, ship logs centrally, redact secrets at the application layer, and alert on disk usage. Do not depend on unlimited local JSON logs.

Question 50Hard

Docker architecture scenario: You need centralized logs with bounded local disk usage. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use log rotation, ship logs centrally, redact secrets at the application layer, and alert on disk usage. Do not depend on unlimited local JSON logs.

Question 51Medium

Docker security scenario: Logs include tokens, passwords, or personal data. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use log rotation, ship logs centrally, redact secrets at the application layer, and alert on disk usage. Do not depend on unlimited local JSON logs.

Question 52Hard

Docker release scenario: You are changing Docker logging drivers and retention. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use log rotation, ship logs centrally, redact secrets at the application layer, and alert on disk usage. Do not depend on unlimited local JSON logs.

Question 53Medium

Docker reliability/cost scenario: Disk pressure causes containers to fail scheduling. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use log rotation, ship logs centrally, redact secrets at the application layer, and alert on disk usage. Do not depend on unlimited local JSON logs.

Question 54Hard

Docker incident: A critical CVE appears in a base image used by many services. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: SBOM scan, image digest comparison, signature verification, and base image dependency graph. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Pin by digest for production, rebuild regularly, sign images, generate SBOMs, block critical vulnerabilities with expiry-based exceptions, and define owners for every base image.

Question 55Hard

Docker architecture scenario: You need a repeatable image rebuild and promotion process. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Pin by digest for production, rebuild regularly, sign images, generate SBOMs, block critical vulnerabilities with expiry-based exceptions, and define owners for every base image.

Question 56Medium

Docker security scenario: Images are built from unpinned tags and cannot be reproduced. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Pin by digest for production, rebuild regularly, sign images, generate SBOMs, block critical vulnerabilities with expiry-based exceptions, and define owners for every base image.

Question 57Hard

Docker release scenario: You are enforcing signed images and SBOM generation. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Pin by digest for production, rebuild regularly, sign images, generate SBOMs, block critical vulnerabilities with expiry-based exceptions, and define owners for every base image.

Question 58Medium

Docker reliability/cost scenario: Security exceptions are piling up because ownership is unclear. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Pin by digest for production, rebuild regularly, sign images, generate SBOMs, block critical vulnerabilities with expiry-based exceptions, and define owners for every base image.

Question 59Hard

Docker incident: A Compose stack starts but the app fails because the database is not ready. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker compose ps, service health, app retry logs, and DNS checks between services. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use health checks plus application-level retries, keep service names stable, avoid hardcoded localhost between containers, and document reset commands.

Question 60Hard

Docker architecture scenario: You need deterministic local environments for onboarding. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use health checks plus application-level retries, keep service names stable, avoid hardcoded localhost between containers, and document reset commands.

Question 61Medium

Docker security scenario: Default Compose networks expose services more broadly than intended. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use health checks plus application-level retries, keep service names stable, avoid hardcoded localhost between containers, and document reset commands.

Question 62Hard

Docker release scenario: You are adding dependency health checks to Compose files. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use health checks plus application-level retries, keep service names stable, avoid hardcoded localhost between containers, and document reset commands.

Question 63Medium

Docker reliability/cost scenario: New engineers waste time debugging local startup order. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use health checks plus application-level retries, keep service names stable, avoid hardcoded localhost between containers, and document reset commands.

Question 64Hard

Docker incident: Security requires rootless Docker but builds and mounts start failing. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: rootless Docker diagnostics, UID mapping checks, mount permission checks, and CI runner logs. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use rootless mode where compatible, avoid privileged Docker-in-Docker, prefer BuildKit/buildx or remote builders, and document volume permission constraints.

Question 65Hard

Docker architecture scenario: You need safer local and CI container execution. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use rootless mode where compatible, avoid privileged Docker-in-Docker, prefer BuildKit/buildx or remote builders, and document volume permission constraints.

Question 66Medium

Docker security scenario: Privileged containers can mutate the host. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use rootless mode where compatible, avoid privileged Docker-in-Docker, prefer BuildKit/buildx or remote builders, and document volume permission constraints.

Question 67Hard

Docker release scenario: You are moving CI runners away from privileged Docker-in-Docker. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use rootless mode where compatible, avoid privileged Docker-in-Docker, prefer BuildKit/buildx or remote builders, and document volume permission constraints.

Question 68Medium

Docker reliability/cost scenario: Security review blocks container platform adoption. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use rootless mode where compatible, avoid privileged Docker-in-Docker, prefer BuildKit/buildx or remote builders, and document volume permission constraints.

Question 69Hard

Docker incident: Intermittent DNS failures occur only inside containers. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: cat /etc/resolv.conf inside the container, nslookup, Docker daemon DNS config, and host resolver logs. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use reliable upstream resolvers, avoid tiny DNS timeouts, keep search domains intentional, and make applications retry DNS failures with backoff.

Question 70Hard

Docker architecture scenario: You need reliable name resolution in containerized workloads. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use reliable upstream resolvers, avoid tiny DNS timeouts, keep search domains intentional, and make applications retry DNS failures with backoff.

Question 71Medium

Docker security scenario: Containers bypass corporate DNS controls. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use reliable upstream resolvers, avoid tiny DNS timeouts, keep search domains intentional, and make applications retry DNS failures with backoff.

Question 72Hard

Docker release scenario: You are changing DNS settings for Docker daemon or Compose. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use reliable upstream resolvers, avoid tiny DNS timeouts, keep search domains intentional, and make applications retry DNS failures with backoff.

Question 73Medium

Docker reliability/cost scenario: Transient DNS failures trigger retry storms. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use reliable upstream resolvers, avoid tiny DNS timeouts, keep search domains intentional, and make applications retry DNS failures with backoff.

Question 74Hard

Docker incident: A non-root container cannot write to mounted directories in production. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: id, ls -ln, mount metadata, Dockerfile USER, and storage driver details. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Set a stable runtime UID, create writable directories at build time, align volume ownership, and fail CI if images run as root without an approved exception.

Question 75Hard

Docker architecture scenario: You need non-root images that still work with persistent storage. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Set a stable runtime UID, create writable directories at build time, align volume ownership, and fail CI if images run as root without an approved exception.

Question 76Medium

Docker security scenario: Teams switch back to root to bypass permission errors. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Set a stable runtime UID, create writable directories at build time, align volume ownership, and fail CI if images run as root without an approved exception.

Question 77Hard

Docker release scenario: You are standardizing UID/GID across images. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Set a stable runtime UID, create writable directories at build time, align volume ownership, and fail CI if images run as root without an approved exception.

Question 78Medium

Docker reliability/cost scenario: Permission issues slow every deployment. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Set a stable runtime UID, create writable directories at build time, align volume ownership, and fail CI if images run as root without an approved exception.

Question 79Hard

Docker incident: Images work on amd64 but fail on arm64 nodes. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker buildx imagetools inspect, uname -m, binary architecture checks, and manifest list inspection. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Build and test per architecture, publish multi-arch manifests, avoid downloading architecture-specific binaries without checks, and run smoke tests on each target architecture.

Question 80Hard

Docker architecture scenario: You need one release process for mixed architecture fleets. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Build and test per architecture, publish multi-arch manifests, avoid downloading architecture-specific binaries without checks, and run smoke tests on each target architecture.

Question 81Medium

Docker security scenario: Architecture-specific binaries are copied into generic images. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Build and test per architecture, publish multi-arch manifests, avoid downloading architecture-specific binaries without checks, and run smoke tests on each target architecture.

Question 82Hard

Docker release scenario: You are adding buildx multi-platform builds. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Build and test per architecture, publish multi-arch manifests, avoid downloading architecture-specific binaries without checks, and run smoke tests on each target architecture.

Question 83Medium

Docker reliability/cost scenario: ARM migration savings are blocked by image incompatibility. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Build and test per architecture, publish multi-arch manifests, avoid downloading architecture-specific binaries without checks, and run smoke tests on each target architecture.

Question 84Hard

Docker incident: The Docker host runs out of disk even after containers are removed. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker system df -v, image/container/volume lists, builder cache usage, and filesystem mount checks. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Separate build cache cleanup from runtime data cleanup, label protected volumes, set retention windows, and monitor Docker root filesystem usage.

Question 85Hard

Docker architecture scenario: You need predictable cleanup without deleting active data. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Separate build cache cleanup from runtime data cleanup, label protected volumes, set retention windows, and monitor Docker root filesystem usage.

Question 86Medium

Docker security scenario: A cleanup job removes volumes still needed by stateful containers. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Separate build cache cleanup from runtime data cleanup, label protected volumes, set retention windows, and monitor Docker root filesystem usage.

Question 87Hard

Docker release scenario: You are adding scheduled pruning on shared build hosts. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Separate build cache cleanup from runtime data cleanup, label protected volumes, set retention windows, and monitor Docker root filesystem usage.

Question 88Medium

Docker reliability/cost scenario: Build agents fail randomly due to disk pressure. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Separate build cache cleanup from runtime data cleanup, label protected volumes, set retention windows, and monitor Docker root filesystem usage.

Question 89Hard

Docker incident: A CI job mounting /var/run/docker.sock can control unrelated host containers. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: CI config review, socket mount search, runner permissions, and audit logs. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use isolated builders, rootless build tools, remote BuildKit, or per-job ephemeral runners. Treat Docker socket access as privileged and require explicit approval.

Question 90Hard

Docker architecture scenario: You need container builds without broad host control. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use isolated builders, rootless build tools, remote BuildKit, or per-job ephemeral runners. Treat Docker socket access as privileged and require explicit approval.

Question 91Medium

Docker security scenario: Docker socket access is effectively root on the host. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use isolated builders, rootless build tools, remote BuildKit, or per-job ephemeral runners. Treat Docker socket access as privileged and require explicit approval.

Question 92Hard

Docker release scenario: You are replacing socket mounts in CI pipelines. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use isolated builders, rootless build tools, remote BuildKit, or per-job ephemeral runners. Treat Docker socket access as privileged and require explicit approval.

Question 93Medium

Docker reliability/cost scenario: Compliance requires stronger isolation for build jobs. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use isolated builders, rootless build tools, remote BuildKit, or per-job ephemeral runners. Treat Docker socket access as privileged and require explicit approval.

Question 94Hard

Docker incident: The same image behaves differently between staging and production. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker inspect, environment diff, image digest comparison, and config source review. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Build once and promote by digest, inject environment config at runtime, keep secrets outside the image, and make startup validate required config.

Question 95Hard

Docker architecture scenario: You need immutable images with environment-specific runtime config. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Build once and promote by digest, inject environment config at runtime, keep secrets outside the image, and make startup validate required config.

Question 96Medium

Docker security scenario: Secrets and config are baked into images. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Build once and promote by digest, inject environment config at runtime, keep secrets outside the image, and make startup validate required config.

Question 97Hard

Docker release scenario: You are removing environment-specific image builds. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Build once and promote by digest, inject environment config at runtime, keep secrets outside the image, and make startup validate required config.

Question 98Medium

Docker reliability/cost scenario: Promotions are slow because every environment rebuilds artifacts. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Build once and promote by digest, inject environment config at runtime, keep secrets outside the image, and make startup validate required config.

Question 99Hard

Docker incident: Requests fail during container termination. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: docker stop timing, signal handling tests, app logs, and load balancer drain metrics. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Use exec-form entrypoints, handle SIGTERM, stop accepting new work before exit, configure grace periods, and test termination behavior under load.

Question 100Hard

Docker architecture scenario: You need zero-loss rolling restarts. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Use exec-form entrypoints, handle SIGTERM, stop accepting new work before exit, configure grace periods, and test termination behavior under load.

Question 101Medium

Docker security scenario: PID 1 does not forward signals to the application. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Use exec-form entrypoints, handle SIGTERM, stop accepting new work before exit, configure grace periods, and test termination behavior under load.

Question 102Hard

Docker release scenario: You are changing base images and init behavior. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Use exec-form entrypoints, handle SIGTERM, stop accepting new work before exit, configure grace periods, and test termination behavior under load.

Question 103Medium

Docker reliability/cost scenario: Deployments cause short but visible error spikes. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Use exec-form entrypoints, handle SIGTERM, stop accepting new work before exit, configure grace periods, and test termination behavior under load.

Question 104Hard

Docker incident: A minimal production image lacks shell tools during an incident. How do you investigate, recover service, and prevent the same failure?

#
Show answer

Start by proving scope and recent change: container logs, /proc inspection from host or sidecar, debug image attach, and orchestrator debug features. Check logs, metrics, health checks, dependency errors, and config drift before changing anything. Recover with the smallest reversible action, then document the root cause. Prevention: Keep production images minimal, maintain a matching debug image, rely on structured logs and metrics, and use controlled debug workflows instead of shipping shells everywhere.

Question 105Hard

Docker architecture scenario: You need debuggability without increasing production attack surface. What design would you choose, and what tradeoffs would you call out in an interview?

#
Show answer

Design for failure domains, rollback, observability, and least privilege first. Validate capacity, limits, network paths, and operational ownership. The practical answer is not one service or command; it is the architecture plus the runbook. For this scenario: Keep production images minimal, maintain a matching debug image, rely on structured logs and metrics, and use controlled debug workflows instead of shipping shells everywhere.

Question 106Medium

Docker security scenario: Debug tools introduce extra CVEs and shell access. How do you harden it without breaking production?

#
Show answer

Baseline current behavior, add guardrails in report-only or staged mode where possible, and test the highest-risk paths first. Roll out with logs, alerts, and a rollback plan. Use least privilege, explicit ownership, and automated checks. For this scenario: Keep production images minimal, maintain a matching debug image, rely on structured logs and metrics, and use controlled debug workflows instead of shipping shells everywhere.

Question 107Hard

Docker release scenario: You are moving to distroless or scratch images. How do you ship the change safely?

#
Show answer

Separate build, deploy, validation, and cutover. Use canary or blue/green where possible, keep the old path available until health checks pass, and define rollback before starting. Watch saturation, errors, latency, and user-facing checks. For this scenario: Keep production images minimal, maintain a matching debug image, rely on structured logs and metrics, and use controlled debug workflows instead of shipping shells everywhere.

Question 108Medium

Docker reliability/cost scenario: Incidents take longer because engineers cannot inspect runtime state. What signals do you inspect and what changes do you make?

#
Show answer

Look at utilization, error rate, latency, queue depth, throttling, quota, retry volume, and recent deployment history. Optimize the bottleneck rather than guessing. Prefer rightsizing, caching, batching, and lifecycle policies before broad rewrites. For this scenario: Keep production images minimal, maintain a matching debug image, rely on structured logs and metrics, and use controlled debug workflows instead of shipping shells everywhere.

Question 109EasyBuild quality

What does docker build --check catch, and where does it fit in CI?

#

Reviewers keep catching the same Dockerfile mistakes by hand, such as shell-form CMD and relative WORKDIR.

Show answer

Build checks, available since Buildx 0.15, evaluate a Dockerfile and its build options against a set of rules without producing an image. Because they run inside the build system, they see build arguments and base images, not just text. Typical findings are shell-form CMD or ENTRYPOINT that will not forward signals, relative WORKDIR paths and mismatched keyword casing.

Run docker build --check . early in CI on every pull request. Add # check=error=true to the Dockerfile so violations fail the build, and skip specific rules only with a written reason.

Trade-offs

Built-in checks need no extra tool but cover fewer rules than a dedicated linter; some teams run both.

Common mistake

Leaving checks as warnings that nobody reads in CI logs.

Follow-up

Which rule would you enforce first in a repository with 40 Dockerfiles?

Question 110MediumSecurity

How do you harden a container's runtime privileges without breaking the app?

#

A web service runs as root with default capabilities and a writable filesystem.

Show answer

Run as a non-root user set in the image. Drop all Linux capabilities and add back only what is needed, for example --cap-drop ALL --cap-add NET_BIND_SERVICE if it must bind a low port (or just listen on a high port). Make the root filesystem read-only with --read-only and mount writable tmpfs only where the app writes. Add --security-opt no-new-privileges so setuid binaries cannot raise privileges, and keep the default seccomp profile.

Never run --privileged or mount the Docker socket into application containers. Test each change in staging and read the errors; they usually name the missing permission.

Trade-offs

Tight defaults reduce blast radius but can surface hidden writes to the filesystem that need fixing first.

Common mistake

Adding --privileged to fix one permission error.

Follow-up

How would you find every path the application writes to before making the filesystem read-only?

Question 111MediumTroubleshooting

How do you debug a distroless container that has no shell?

#

A production container misbehaves, but docker exec ... sh fails because the image has no shell or tools.

Show answer

Start a separate tools container that joins the target's namespaces: docker run -it --rm --pid=container:app --network=container:app <tools-image> lets you see its processes and network from a full toolset, without changing the production image. You can read its files through /proc/<pid>/root when you have permission.

On Kubernetes, kubectl debug -it <pod> --image=<tools-image> --target=<container> adds an ephemeral container that shares the target's process namespace. Keep debug images approved and pinned, and remove access afterwards.

Trade-offs

Shipping without a shell reduces attack surface but means you must prepare debug tooling in advance.

Common mistake

Rebuilding the production image with a shell during an incident.

Follow-up

Which tools would you put in your team's standard debug image?

Question 112MediumAI

What is Docker Model Runner, and how is it different from running a model in a container?

#

Developers want a local LLM for testing an app that normally calls a hosted OpenAI-compatible API.

Show answer

Docker Model Runner pulls models packaged as OCI artifacts from Docker Hub, another OCI registry or Hugging Face, and serves them through OpenAI- and Ollama-compatible APIs, so an app can switch by changing its base URL. It supports inference engines such as llama.cpp, vLLM and Diffusers. Inference runs as a host-level process managed by Docker, which gives it direct access to the GPU, rather than inside your app container.

The docs warn that its API is not authenticated: anything that can reach it, including other containers on the same network, can load and run models. Keep it on developer machines or protected networks, and pin model tags like image tags.

Trade-offs

It makes local model testing easy with familiar tooling, but production serving still needs proper capacity planning, auth and monitoring.

Common mistake

Exposing the model endpoint on a shared network because "it is only for dev".

Follow-up

How would you make CI tests that call a local model deterministic enough to be useful?

Question 113MediumBuild security

A security scan found your private npm token inside a published image, even though the Dockerfile deletes .npmrc after install. How did it leak, and what is the right fix?

#

The pipeline runs docker build --build-arg NPM_TOKEN=...; the Dockerfile writes the token to .npmrc, runs npm ci, then rm .npmrc in a later step.

Show answer

Two leaks are possible here. Build arguments and environment variables persist in the image, so anyone who pulls it can read them from the image config and history. And writing .npmrc in one layer and deleting it in a later layer does not remove it: the earlier layer still contains the file, and pulling the image gives you every layer.

Docker's own guidance is blunt: build arguments and environment variables are inappropriate for passing secrets. Use a secret mount instead. The client passes the secret with --secret id=npmrc,src=$HOME/.npmrc, and the one RUN step that needs it mounts it with --mount=type=secret. By default the secret appears at /run/secrets/<id>; target= puts it somewhere else, and env= exposes it as an environment variable for that step only. The file is never written into a layer.

For private Git dependencies, use an SSH mount (--ssh default) rather than copying a key in.

After fixing the Dockerfile, treat the token as compromised: revoke it, rebuild, and delete or overwrite the leaked tags in the registry, because old digests stay pullable.

Trade-offs

Secret mounts need BuildKit and a small change to every build command, but they are the only option that keeps the value out of every layer and the image config.

Common mistake

Squashing or deleting the file in a later layer and assuming the secret is gone, without rotating it.

Follow-up

How would you scan your registry for images that already contain credentials in their history?

Token is mounted for one step and never stored in a layer · dockerfile
# syntax=docker/dockerfile:1
FROM node:22-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci
COPY . .
Pass the secret at build time · shell
docker build --secret id=npmrc,src=$HOME/.npmrc -t app:1.4.0 .
Question 114MediumBuild security

You switched CI to build straight from a private Git URL instead of a checkout. The build cannot fetch the repo, and once it can, git describe fails inside the build. Why both?

#

The job runs docker build https://github.com/acme/api.git#main and the Dockerfile stamps the version with git describe --tags.

Show answer

With a remote Git context, the builder does the clone, not your CI checkout step, so it needs its own credentials. BuildKit has two predefined pre-flight secrets for this: GIT_AUTH_TOKEN, sent as Basic auth with the fixed username x-access-token (suits GitHub), and GIT_AUTH_HEADER, which sends exactly the value you give as the Authorization header (suits providers such as GitLab). You can scope them per host with a suffix, for example id=GIT_AUTH_TOKEN.github.com. They are used to fetch the context and are not exposed to Dockerfile steps.

The second failure is by design. The builder makes a shallow clone of only the HEAD commit, and by default it does not keep the .git directory at all, so there are no tags or history to describe. Set the BUILDKIT_CONTEXT_KEEP_GIT_DIR build argument if you truly need Git metadata.

A cleaner recommendation: compute the version in CI, where you control fetch depth and tags, and pass it in as a normal build argument (a version string is not a secret). That keeps the build reproducible from a single commit.

Trade-offs

Remote contexts avoid sending a large local context and guarantee the build matches a commit, but you lose the Git metadata and local tooling a checkout gives you.

Common mistake

Passing the Git token as a build argument, which stores it in the image.

Follow-up

When would you use a named build context (--build-context) instead of a remote Git URL?

Pre-flight Git credentials for a remote context · shell
GIT_AUTH_TOKEN=$(gh auth token) docker build \
  --secret id=GIT_AUTH_TOKEN \
  --build-arg VERSION=$(git describe --tags) \
  https://github.com/acme/api.git#main
Question 115HardBuild performance

CI imports a registry cache on every run, yet the expensive compile stage of your multi-stage build always runs from scratch. What is wrong?

#

The job uses --cache-to type=registry,ref=reg.example.com/api:buildcache and --cache-from the same ref. Only the final small runtime stage ever hits cache.

Show answer

The cache exporter defaults to mode=min, which caches only the layers exported into the resulting image. In a multi-stage build the compile stage is not part of the final image, so its layers are never written to the remote cache, and every fresh runner has to rebuild them.

Set mode=max on --cache-to. Max mode caches all layers, including intermediate stages, so the builder stage can be reused. The trade-off is size: min caches are smaller and faster to import and export and cost less storage, while max caches are more likely to hit.

Two more things to check. With the default docker driver, the registry, local, inline and gha backends work only if the containerd image store is enabled; otherwise use a docker-container builder. And BuildKit can import from several caches, so a branch build can read its own cache and fall back to the main branch's. Never let two jobs write to the same cache location, though: writing a location again overwrites what was cached there.

Trade-offs

mode=max raises registry storage and export time; mode=min is cheap but useless for stages that are not shipped.

Common mistake

Adding more cache-from sources while the exporter still never writes the stage you need.

Follow-up

How would you measure the cache hit rate of each stage across a week of CI runs?

Export intermediate stages too, and fall back to main · shell
docker buildx build \
  --cache-to type=registry,ref=reg.example.com/api:cache-$BRANCH,mode=max \
  --cache-from type=registry,ref=reg.example.com/api:cache-$BRANCH \
  --cache-from type=registry,ref=reg.example.com/api:cache-main \
  -t reg.example.com/api:$SHA --push .
Question 116HardBuild performance

One GitHub Actions workflow builds three images with the gha cache backend. Each build seems to wipe out the others' cache. Why?

#

Three jobs in a matrix all use cache-to: type=gha and cache-from: type=gha with no other options. Cache hits are random and mostly misses.

Show answer

The gha backend identifies its cache object with a scope, and the default scope is buildkit. Three different images writing to the same scope overwrite one another, so each build imports whichever image's cache was written last, and mostly misses.

Give each image its own scope, for example scope=api, scope=web and scope=worker. If branches should not fight over one cache either, include the branch in the scope and add a second cache-from that reads the main branch's scope as a fallback.

Also remember the limits you do not control: GitHub applies its own cache size and usage limits and removes stale entries after a while, so a cache written by a rarely built image may already be gone. And the gha backend works with the default docker driver only when the containerd image store is enabled; otherwise use a docker-container builder (for example the one docker/setup-buildx-action creates). Check the mode too: the gha backend defaults to mode=min, which skips intermediate stages.

Trade-offs

Per-branch scopes give accurate hits but use more of the repository's cache quota and get evicted sooner; a single shared scope is small but thrashes.

Common mistake

Blaming the cache backend as flaky and switching it off, when the jobs were simply sharing one key.

Follow-up

At what point would you move from the gha backend to a registry cache, and why?

One scope per image (docker/build-push-action inputs) · yaml
cache-from: |
  type=gha,scope=api-${{ github.ref_name }}
  type=gha,scope=api-main
cache-to: type=gha,scope=api-${{ github.ref_name }},mode=max
Question 117MediumBuild performance

Every small change to requirements.txt re-downloads 2 GB of Python wheels. How do you make dependency installs fast without bloating the image?

#

The Dockerfile copies the lock file and runs pip install -r requirements.txt. Any change to the file invalidates the layer and every package is downloaded again.

Show answer

Layer caching cannot help here: once the lock file changes, the whole install step reruns from an empty download cache. A cache mount fixes that. RUN --mount=type=cache,target=/root/.cache/pip gives the step a persistent directory that is shared between builds and cumulative across them, so pip reuses wheels it downloaded before and fetches only what changed.

The cache directory is not part of the image layer, so you get speed without shipping the package cache. Use --no-cache-dir only if you are not using a cache mount; with one, you want pip to write to it. For apt, Docker's example uses sharing=locked, because apt needs exclusive access to its data and two parallel builds would otherwise corrupt it.

The common surprise is CI. A cache mount lives with the builder. On an ephemeral runner with a fresh builder every time, the mount starts empty and you gain little. Measure on your real runners; if they are ephemeral, rely on a persistent builder or on a well-structured layer cache exported to a registry, and keep the cache mount for local and long-lived builders.

Trade-offs

Cache mounts make local and persistent-builder builds much faster, but they add nothing on throwaway builders and can hide a slow, unpinned dependency resolution.

Common mistake

Expecting a cache mount to help on ephemeral CI runners without checking whether the builder persists.

Follow-up

How would you combine a cache mount with a bind mount of the lock file so the install step does not need a COPY layer at all?

Reuse downloaded packages across builds · dockerfile
# syntax=docker/dockerfile:1
FROM python:3.13-slim
WORKDIR /app
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r requirements.txt
COPY . .
Question 118MediumSupply chain

Your team turned on SBOM and max provenance for compliance, and local builds now fail with "Attestation is not supported for the docker driver". What is going on, and what changes for consumers of the image?

#

CI pushes images with --sbom=true --provenance=mode=max. Developers running the same command on older Docker Engine installs get the error.

Show answer

Attestations attach to an image as extra manifests in the image index; each attestation manifest refers to one platform image manifest. The classic image store does not support image indexes, so it cannot hold an image with attestations, and the default docker driver refuses the build unless the containerd image store is enabled. The local and tar exporters cannot save attestations either.

Fixes: enable the containerd image store (it is the default on fresh Docker Engine 29.0+ installs, but upgraded hosts keep overlay2 until you switch), use a docker-container builder, or push straight to the registry, which keeps the attestations.

By default, BuildKit already adds mode=min provenance; mode=max is opt-in, and you can turn defaults off with --provenance=false or the BUILDX_NO_DEFAULT_ATTESTATIONS variable. Be careful with max provenance on private code: it records much more about how the image was built.

For consumers, the pushed tag now points to an index rather than a single manifest. Scripts that assumed one manifest per tag, or tools that inspect the raw manifest, should be tested before you roll this out widely.

Trade-offs

Attestations give auditors a verifiable build record and SBOM, at the cost of a more complex image structure and a dependency on the containerd store or a container builder.

Common mistake

Disabling attestations everywhere to make the local error go away, including in the CI job that compliance depends on.

Follow-up

How would you verify, at deploy time, that an image carries provenance from your own CI builder?

Question 120EasyDockerfile

You declared ARG PYTHON_VERSION=3.13 at the top of the Dockerfile. FROM uses it correctly, but a later RUN prints an empty value. Why?

#

The Dockerfile starts with ARG PYTHON_VERSION=3.13, then FROM python:${PYTHON_VERSION}-slim, then RUN echo $PYTHON_VERSION > /version. The file is empty.

Show answer

An ARG declared before the first FROM lives outside any build stage. It can be used in FROM lines, but not by instructions after a FROM. Each stage starts with its own scope.

To use the value inside the stage, redeclare it with no value after FROM: ARG PYTHON_VERSION. The stage then inherits the default from the global declaration (or the value passed with --build-arg). In a multi-stage build you must do this in every stage that needs it.

This bites hardest in version stamping and in multi-stage builds where only one stage redeclares the argument, so one stage silently gets an empty string. A quick guard is to fail early in the stage: RUN test -n "$PYTHON_VERSION".

Trade-offs

Stage-scoped arguments keep stages independent and cache-friendly, at the cost of repeating declarations.

Common mistake

Switching the value to ENV at the top of the file, which also does not cross FROM and bakes the value into the image.

Follow-up

How do build arguments affect the build cache when their value changes?

Redeclare the global ARG inside the stage · dockerfile
ARG PYTHON_VERSION=3.13
FROM python:${PYTHON_VERSION}-slim
ARG PYTHON_VERSION
RUN echo "$PYTHON_VERSION" > /version
Question 121MediumRuntime

Every docker stop of your service takes exactly 10 seconds and ends with exit code 137, and in-flight requests are lost. What is the cause, and how do you fix it properly?

#

The image uses ENTRYPOINT /app/start.sh (shell form). The script exports a few variables and then runs node server.js.

Show answer

docker stop sends the stop signal (SIGTERM unless STOPSIGNAL says otherwise), waits for the stop timeout, which defaults to 10 seconds for Linux containers, and then sends SIGKILL. Exit code 137 is 128 + 9, so the process was killed, not stopped cleanly.

The signal never reached Node. With shell form, the command is wrapped in /bin/sh -c, so the executable is not PID 1 and does not receive Unix signals. Here it is doubly wrapped: a shell runs the script, and the script runs Node as a child.

Fix it in layers. Use exec form: ENTRYPOINT ["/app/start.sh"]. End the script with exec node server.js so Node replaces the shell and becomes PID 1. Make the app handle SIGTERM: stop accepting work, finish in-flight requests, then exit. If the process spawns children or cannot forward signals well, run with --init (Compose: init: true), which runs docker-init, backed by tini, to forward signals and reap zombie processes.

Only then tune the timeout with --stop-timeout (or stop_grace_period in Compose) to cover your real drain time.

Trade-offs

An init process adds a tiny binary but makes signal handling and zombie reaping correct for any app; relying on the app as PID 1 works only if it handles signals itself.

Common mistake

Raising the stop timeout to 60 seconds, which only makes every deploy slower while the app still never sees SIGTERM.

Follow-up

Why does a process running as PID 1 in a container ignore SIGTERM unless it installs a handler?

start.sh: hand PID 1 to the app · shell
#!/bin/sh
set -e
export NODE_ENV=production
exec node /app/server.js
Question 122MediumHealth checks

A JVM service takes 40 to 90 seconds to start. With a 30-second health check interval it is either marked unhealthy too early or becomes healthy minutes late. How do you tune it?

#

The HEALTHCHECK uses --interval=30s --retries=3 and no other options. Dependent services wait on service_healthy.

Show answer

Docker's defaults are an interval of 30 seconds, timeout 30 seconds, 3 retries, and a start period of 0. With no start period, failures during a slow boot count toward the retries, so the container can be marked unhealthy while it is still starting. And with a 30-second interval, a service that is ready at second 41 may not be reported healthy until second 60 or later, which delays everything that depends on it.

Use --start-period to cover the worst-case startup, here around 90 to 120 seconds. Failures inside the start period do not count toward retries, but a success marks the container healthy straight away. Then add --start-interval (default 5 seconds, requires Docker Engine 25.0 or later), which sets how often the check runs during the start period. You get fast detection of readiness during boot and a calmer interval afterwards.

Keep the check itself cheap and local: it should prove the process can serve, not call every downstream dependency, or one slow database will mark every container unhealthy at once.

Trade-offs

A long start period hides a genuinely broken boot for longer; a short one causes false unhealthy states during slow starts.

Common mistake

Shortening the main interval to 5 seconds for everyone, which adds constant probe load forever to fix a startup problem.

Follow-up

Does a Docker HEALTHCHECK have any effect when the image runs on Kubernetes?

Fast checks during boot, calm checks after · dockerfile
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
  --start-period=120s --start-interval=5s \
  CMD ["curl", "-fsS", "http://127.0.0.1:8080/ready"]
Question 123MediumCompose

In your Compose stack, the API sometimes starts before database migrations finish, and after a database restart it keeps serving errors from dead connections. How do you model this in Compose?

#

Services: db (Postgres), migrate (runs migrations and exits), api. Today api has depends_on: [db] only.

Show answer

The short form of depends_on only waits for the dependency to be started, not ready. Compose supports three conditions: service_started, service_healthy (the dependency must pass its health check) and service_completed_successfully (the dependency must run to successful completion first).

Model the real order: db has a health check (for Postgres, pg_isready); migrate depends on db being service_healthy; api depends on migrate with service_completed_successfully and on db with service_healthy. A failed migration now stops the API from starting, which is what you want.

For the restart problem, add restart: true to the db dependency. When db is restarted or updated by an explicit Compose operation, Compose restarts api too, so it does not hold dead connections. That covers Compose-driven restarts, not a database that crashes on its own, so the app should still reconnect with backoff.

Remember this is local and test orchestration. In production, the app must tolerate its dependencies going away at any time.

Trade-offs

Strict conditions make local stacks deterministic but slower to start; they also hide the missing retry logic that production needs.

Common mistake

Adding sleep 20 to the API entrypoint instead of declaring the dependency.

Follow-up

How would you make the same ordering guarantee in Kubernetes without init-container sleeps?

Order: healthy database, then migrations, then API · yaml
services:
  db:
    image: postgres:18
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 10s
      retries: 5
      start_period: 30s
  migrate:
    build: .
    command: ["./migrate", "up"]
    depends_on:
      db:
        condition: service_healthy
  api:
    build: .
    depends_on:
      migrate:
        condition: service_completed_successfully
      db:
        condition: service_healthy
        restart: true
Question 124HardNetworking security

Your server runs ufw with "deny incoming", yet a pentest reached Redis on port 6379 that you published with -p 6379:6379. How is that possible, and how do you lock it down?

#

A single VM, ufw enabled, Docker Engine on the default iptables backend. Redis was published for a local tool and forgotten.

Show answer

Docker documents that ufw and Docker are incompatible for published ports. Docker routes container traffic in the nat table, so packets are diverted before they reach the INPUT and OUTPUT chains that ufw uses. And by default, a published port is bound to all host addresses (0.0.0.0 and [::]); Docker's own docs say publishing container ports is insecure by default.

Lock it down in this order:

1. Do not publish what does not need to be public. Containers on the same user-defined network reach each other by name without any -p. 2. If a port is only for the host, bind it to loopback: -p 127.0.0.1:6379:6379. Note that in releases older than 28.0.0, hosts on the same L2 segment could still reach ports published to localhost, so upgrade old engines. 3. Change the default bind address: the ip key in daemon.json for the default bridge, or com.docker.network.bridge.host_binding_ipv4 per user-defined network. 4. For rules that must filter published traffic, use the DOCKER-USER chain, which runs before Docker's own forwarding rules. Packets there are already DNAT-ed, so match the original destination with conntrack (--ctorigdst, --ctorigdstport).

Do not set iptables: false: Docker says it will likely break container networking.

Trade-offs

Binding to loopback is simple and safe; DOCKER-USER rules are flexible but easy to get wrong and must be persisted across reboots.

Common mistake

Adding a ufw deny rule for 6379 and believing the port is closed.

Follow-up

How does this change if the host moves to Docker's nftables firewall backend?

Allow only one source to reach published ports from outside · shell
sudo iptables -I DOCKER-USER -i eth0 ! -s 192.0.2.2 -j DROP
Question 125HardNetworking

You want to move Docker hosts to the nftables firewall backend. After switching, containers lose outbound connectivity on some hosts and your custom DOCKER-USER rules stop working. What did you miss?

#

Hosts run Docker Engine 29 with "firewall-backend": "nftables" in daemon.json. A few of them are also Swarm nodes.

Show answer

Docker's nftables support arrived in Docker 29.0.0 and is still experimental, so treat this as a pilot, not a fleet-wide change.

Three documented differences explain the symptoms. First, with the nftables backend Docker does not enable IP forwarding itself; it reports an error if forwarding is needed but not enabled. Hosts where something else had turned forwarding on keep working; the others lose container egress. Enable net.ipv4.ip_forward (and the IPv6 equivalent if used) in your host configuration explicitly. Second, there is no DOCKER-USER chain in the nftables implementation. Your rules must move into your own nftables tables with base chains that use the same types and hook points as Docker's. Third, nftables cannot be enabled when the daemon runs in Swarm mode, because overlay network rules have not been migrated from iptables yet, so Swarm nodes must stay on iptables.

Plan: inventory hosts that rely on DOCKER-USER or Swarm, rewrite the custom rules as nftables tables, set forwarding explicitly, canary on a few hosts, and compare connectivity and published-port behaviour before going wider.

Trade-offs

nftables gives you one modern rule set on distros moving away from iptables, but it is experimental and drops conveniences such as DOCKER-USER and automatic forwarding.

Common mistake

Flipping the backend fleet-wide in one change and discovering the Swarm and forwarding limits in production.

Follow-up

How would you test published-port exposure automatically after any firewall change?

daemon.json on a non-Swarm pilot host · json
{
  "firewall-backend": "nftables"
}
Question 126MediumLogging

After a disk-full incident you added log rotation to daemon.json and restarted Docker, but a week later the same container filled the disk again. Why?

#

You set "log-opts": {"max-size": "50m", "max-file": "3"} for the json-file driver and restarted the daemon. The noisy container was not recreated.

Show answer

The json-file driver's defaults are max-size of -1 (unlimited) and max-file of 1, so out of the box logs are never rotated. That caused the first incident.

Your fix only applies to newly created containers. Docker's docs say existing containers do not use the new logging configuration automatically. A container keeps the log settings it was created with, so the noisy container kept writing one unbounded file. Recreate it (in Compose, docker compose up -d --force-recreate, or any redeploy that creates a new container) and check the result with docker inspect --format '{{.HostConfig.LogConfig}}' <container>.

Also note that max-file only takes effect when max-size is set, and compression is off by default (compress is false). Set defaults in daemon.json as a safety net, and set explicit log options per service in Compose so the limit travels with the service definition. Long term, ship logs off the host and keep local logs short.

Trade-offs

Small local logs protect the disk but shorten what you can read during an incident if shipping is down.

Common mistake

Truncating the log file by hand and calling the incident fixed.

Follow-up

Which containers on a host are still running with unbounded logs, and how would you find them in one command?

Per-service limits that travel with the Compose file · yaml
services:
  api:
    image: reg.example.com/api:2.1.0
    logging:
      driver: json-file
      options:
        max-size: "50m"
        max-file: "3"
Question 127HardOperations

You enabled live-restore so daemon upgrades would not restart containers, but the last upgrade still stopped them all, and during a long daemon outage some containers hung. Explain both.

#

Standalone Docker hosts running long-lived services. "live-restore": true is set. The team upgraded Docker Engine from one major release to the next.

Show answer

Live restore keeps containers running while the daemon is unavailable, but only within limits. It is supported when installing patch releases (YY.MM.x), not for major daemon upgrades between YY.MM versions, and skipping releases can stop the daemon from reconnecting to containers. Your major upgrade was outside what it covers. Changes to daemon-level options such as the bridge IP addresses or the storage driver can also prevent restore. It applies only to standalone containers, not Swarm services.

The hang is the log buffer. While the daemon is down, containers write logs into a FIFO the daemon would normally read. The buffer defaults to 64K; once full, the container cannot write more logs and blocks, and you must restart the daemon to flush it. On Linux you can raise it via /proc/sys/fs/pipe-max-size.

So use live-restore to make patch upgrades and daemon restarts painless, and enable it with systemctl reload docker to avoid a restart. For major upgrades, drain the host (move traffic away), upgrade, and bring it back, the same as any other planned maintenance.

Trade-offs

Live restore removes most daemon-restart outages, but it can make you forget that major upgrades still need a drain.

Common mistake

Treating live-restore as a zero-downtime guarantee for every Docker upgrade.

Follow-up

How would you roll a major Docker Engine upgrade across 50 standalone hosts without user impact?

Question 128HardStorage

After you enabled the containerd image store on a build host, docker images was empty, old containers were missing, and disk use grew. Was data lost?

#

An upgraded Docker Engine 29 host still on overlay2. You added the containerd-snapshotter feature to get multi-platform builds and attestations locally.

Show answer

No data was lost. Switching storage backends hides the images and containers created with the other backend: the overlay2 data stays on disk and reappears if you switch back. Docker does not migrate it for you in the normal path; its guidance is to push images to a registry or docker save them first, and it recommends starting fresh over the experimental automatic migration.

The disk growth is expected too. The containerd store keeps compressed layers and also extracts them, so it uses more space than the legacy drivers for the same images. It also uses its own storage path, so a custom Docker data directory does not carry over automatically, which matters if you moved data-root to a large volume. While both stores exist, you pay for both.

Why switch at all? The containerd store can build and hold multi-platform images and images with attestations locally, which classic drivers cannot. It is the default for fresh Docker Engine 29.0+ installs, while upgraded daemons stay on overlay2 until you opt in (and it does not apply to daemons using userns-remap). Plan the switch: push what you need, check where containerd will store data, switch, then prune the old store once you are sure you will not roll back.

Trade-offs

You gain multi-platform and attestation support locally, and pay in disk space and a one-time migration.

Common mistake

Running a full prune right after switching to "clean up", then needing to roll back.

Follow-up

How would you size disks for build hosts once every host uses the containerd store?

/etc/docker/daemon.json · json
{
  "features": {
    "containerd-snapshotter": true
  }
}
Question 129MediumUpgrades

After upgrading build hosts to Docker Engine 29.0, an old CI plugin and a legacy deploy tool can no longer talk to the daemon. Why, and how do you plan around it?

#

The tools embed an old Docker client library that negotiates an old API version. Newer Docker CLIs on the same hosts work fine.

Show answer

Docker Engine 29.0.0 (released 2025-11-10) raised the minimum API version the daemon accepts to v1.44, which corresponds to Docker v25.0. Clients that only speak older API versions are rejected. Docker later lowered the minimum to v1.40 (Docker 19.03) in 29.3.0, so very old clients are still out, but more are back in.

The right plan is to treat the Docker API like any other dependency. Inventory every client of the daemon: CLIs, SDKs embedded in CI plugins, monitoring agents and deploy tools. Upgrade their client libraries, or pin to a version that negotiates a supported API. Canary one host with the new engine before the fleet.

Read the rest of the 29.0 notes during the same review. Among other changes, the containerd image store became the default for fresh installs, cgroup v1 is deprecated (supported until at least May 2029), and Docker Content Trust was removed from the CLI. Any one of these can break a long-forgotten script.

Trade-offs

Upgrading the engine first gets security fixes sooner; upgrading clients first avoids an outage. With an inventory you can do clients first, then engines.

Common mistake

Pinning the whole fleet to an old engine to keep one unmaintained tool working.

Follow-up

How would you find every process on a host that talks to the Docker socket?

Question 130MediumRegistries

During a big autoscaling event, new CI runners failed to pull base images from Docker Hub. All runners leave through one NAT gateway. What happened and what do you change?

#

Runners pull anonymously. The incident started when about 150 new runners came up within an hour.

Show answer

Docker Hub limits pulls in a 6-hour window. Unauthenticated users get 100 pulls per IPv4 address or IPv6 /64 subnet, authenticated Docker Personal users get 200, and Pro, Team and Business accounts are unlimited. Behind one NAT gateway, every runner looks like the same IPv4 address, so the whole fleet shared one anonymous budget of 100 pulls and ran out.

Fixes, in order of value: authenticate pulls with an organization account so the limit follows the account, not the NAT address; put a pull-through cache or your own registry in front of Docker Hub so most pulls never reach it; and mirror the handful of base images you depend on into your own registry, promoted through your normal scan process.

You can check the budget without spending it. Get a token, send a HEAD request to the image's manifest endpoint (HEAD does not count, GET does), and read the ratelimit-limit, ratelimit-remaining and docker-ratelimit-source headers. If no ratelimit headers come back, the pull is not being counted. Add this to runner health checks so you see the problem coming.

Trade-offs

A paid account is the fastest fix; a pull-through cache costs operational effort but also speeds up pulls and removes an external dependency from your scaling path.

Common mistake

Spreading runners across more NAT IPs to get more anonymous quota, which is fragile and does not fix the dependency.

Follow-up

How would you make sure a Docker Hub outage cannot stop your production deployments?

Question 131HardBuild performance

Adding arm64 to your Go service's image build took CI from 4 minutes to 40. How do you get the time back?

#

The job runs docker buildx build --platform linux/amd64,linux/arm64 on amd64 runners with QEMU installed. The Dockerfile compiles inside a golang stage.

Show answer

Docker supports three strategies for multi-platform images: emulation with QEMU, a builder with multiple native nodes, and cross-compilation in a multi-stage build. Docker warns that emulation can be much slower than native builds, and a compiler running under emulation is the worst case.

For Go, cross-compile. Pin the build stage to the platform of the machine doing the build with FROM --platform=$BUILDPLATFORM, read the automatic TARGETOS and TARGETARCH arguments, and pass them to the compiler. The compile now runs natively on amd64 for both targets, and only the tiny final stage is assembled per platform.

Where you cannot cross-compile (native extensions, some Python or Node packages), use a builder with native arm64 nodes rather than emulation. Keep QEMU for small steps only.

Two practical notes. Multi-platform images need an image store that supports manifest lists, so on the default docker driver you need the containerd image store, and the docker-container driver does not load results into the local image store automatically, so push directly. And test the arm64 image on arm64 hardware before shifting traffic: a successful build does not prove the binary works.

Trade-offs

Cross-compilation is fastest but only works for toolchains that support it; native nodes work for anything but cost more infrastructure.

Common mistake

Throwing bigger runners at a QEMU-emulated compile instead of removing the emulation.

Follow-up

How would you handle a Go service that needs CGO with an arm64 C library?

Compile natively for every target platform · dockerfile
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:1.25 AS build
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/server .

FROM gcr.io/distroless/static-debian12
COPY --from=build /out/server /server
ENTRYPOINT ["/server"]
Question 132MediumResources

You set --memory 1g on a cache container, but under load it slows to a crawl instead of being OOM-killed, and host metrics show it using about 2 GB of memory plus swap. Why?

#

The host has swap enabled. Only --memory was set; --memory-swap was left unset.

Show answer

When --memory-swap is not set and the host has swap configured, the container can use as much swap as its --memory setting. Docker's own example: with --memory=300m and no swap setting, the container can use 600m of memory and swap in total. Your 1g container can therefore use roughly 2g of memory plus swap, and once it starts swapping, latency collapses instead of failing fast.

For latency-sensitive services, set --memory-swap equal to --memory, which leaves no swap, so the container is OOM-killed and restarted rather than limping along. That is usually the better failure: fast, visible and easy to alert on.

Related settings people misuse: --memory-reservation is only a soft limit that applies when Docker detects contention or low memory, and it does not guarantee the container stays under it. --oom-kill-disable should only ever be used together with a memory limit; without one the host can run out of memory and the kernel kills host processes instead. For CPU, --cpus is a hard cap, while --cpu-shares (default weight 1024) only matters when CPU is contended.

Trade-offs

No swap gives predictable latency and clear failures; allowing swap avoids some OOM kills at the cost of unpredictable slowdowns.

Common mistake

Reading --memory as the total memory the container can touch on a host with swap.

Follow-up

How do these Docker flags map onto cgroup v2 files such as memory.max and memory.swap.max?

Fail fast instead of swapping · shell
docker run -d --name cache --memory 1g --memory-swap 1g redis:8
Question 133HardSecurity

Security wants "root in a container must not be root on the host" for a shared Docker host. Do you choose userns-remap or rootless Docker, and what will break?

#

The host runs internal build and test containers for several teams. Some jobs use --network=host, some bind-mount host directories.

Show answer

Both map container root to an unprivileged host identity, but they differ in what runs as root.

With userns-remap, the daemon still runs as root, but container root and the IDs after it are mapped to a subordinate range of 65536 IDs defined in /etc/subuid and /etc/subgid, IDs that have no privileges on the host. It is a daemon-wide setting that is fairly transparent to images. Known limits: sharing the host PID or network namespace (--pid=host, --network=host) is not supported, --privileged does not work without --userns=host (which turns remapping off for that container), host paths and volumes need ownership arranged for the remapped IDs, and enabling it masks existing images and containers, so do it on a fresh install.

Rootless mode runs the daemon and containers without root privileges at all. It removes the most powerful target (a root daemon), but it comes with its own documented limitations, so test your workloads against it before committing.

For this host I would pick userns-remap if most jobs are ordinary containers, and move the --network=host jobs to bridge networking or separate hosts, because they cannot run under it. Choose rootless when even a root daemon is unacceptable, such as on developer machines or untrusted multi-tenant runners. Either way, stop mounting the Docker socket into jobs: socket access is root on the host regardless of remapping.

Trade-offs

userns-remap is low-friction but keeps a root daemon; rootless removes it but adds more compatibility work.

Common mistake

Enabling remapping on a busy existing host and being surprised that every image and container seems to disappear.

Follow-up

How would you give one trusted job host networking without weakening isolation for everyone else?

/etc/docker/daemon.json on a fresh host · json
{
  "userns-remap": "default"
}
Question 134MediumSecurity

A vendor says their agent only works with --security-opt seccomp=unconfined. How do you respond?

#

The agent fails at startup with "operation not permitted" on one syscall. The vendor's install guide also suggests --privileged as an alternative.

Show answer

Docker applies a default seccomp profile to every container unless you override it with --security-opt. The profile is an allowlist that denies access to system calls by default, and Docker describes it as disabling around 44 system calls out of more than 300. unconfined removes that whole layer to allow one call; --privileged goes much further and should be off the table.

Work out which syscall is being denied (an audit log, strace, or the vendor's own debug output), then decide whether allowing it is reasonable for this agent. If it is, start from Docker's default profile, add only that syscall, and run the agent with --security-opt seccomp=/path/agent-profile.json. Keep the custom profile in version control and review it like code.

Also check whether the error really comes from seccomp: an "operation not permitted" can just as well come from a missing Linux capability, and one --cap-add is far narrower than removing the profile. Push back on the vendor with the exact syscall; good vendors will document it.

Trade-offs

A custom profile keeps nearly all protection but becomes something you must maintain on every Docker upgrade; unconfined is easy and gives up the whole layer.

Common mistake

Accepting unconfined or privileged for a third-party agent without knowing which single call it needed.

Follow-up

How would you roll out a custom seccomp profile to the same workload on Kubernetes?

Question 135MediumSupply chain

Your platform team wants to move all services to Docker Hardened Images. What do you gain, what breaks first, and what must you check about the free tier?

#

Services today use full Debian-based official images. Many Dockerfiles run apt-get install and some services write to their working directory at runtime.

Show answer

Docker Hardened Images are minimal images maintained by Docker. Their core features are free to use under Apache 2.0, and each image ships signed SBOMs, VEX statements, SLSA Build Level 3 provenance and signatures. The distroless variants remove unnecessary components; Docker says this reduces attack surface by up to 95%. For you that means fewer CVEs to triage and better evidence for audits.

Two defaults break existing Dockerfiles first. Containers run as non-root by default, so services that write to root-owned paths such as their working directory fail. And distroless variants have no shell or package manager at runtime, so apt-get steps, shell-form entrypoints and docker exec sh debugging stop working. The fix is a multi-stage build: install and compile in a build stage, copy only the result into the hardened runtime image, set writable paths explicitly, and debug with ephemeral debug containers rather than a shell in the image.

Check the tier you actually need. The free Community tier includes the core images, CVE scanning, provenance and SBOMs, but no FIPS or STIG variants, no SLA-backed patching and no customizations. If compliance demands FIPS images or a patch SLA, those are in the paid Select and Enterprise tiers.

Trade-offs

Hardened minimal images cut CVE noise and improve provenance, but they cost a migration of every Dockerfile and change how engineers debug.

Common mistake

Swapping the FROM line across 200 services in one change and discovering the non-root default in production.

Follow-up

How would you verify a hardened image's provenance and VEX data in your admission pipeline?

Question 136MediumDockerfile

In a monorepo, one service's image accidentally contains another team's .env file, and builds upload 3 GB of context. How do you fix the context for several Dockerfiles that share the repo root?

#

Every service builds with the repo root as context and its own Dockerfile (services/api/Dockerfile, services/web/Dockerfile). There is one .dockerignore at the root that excludes only node_modules.

Show answer

Everything in the context that is not ignored is sent to the builder, and a COPY . . copies it into the image, secrets included. One root .dockerignore cannot serve services that need different files.

The build client looks for .dockerignore at the root of the context, but a Dockerfile-specific ignore file placed next to the Dockerfile and named after it (services/api/Dockerfile.dockerignore) takes precedence. Give each service its own, and write them as allowlists: ignore everything with *, then re-include only what that service needs with ! lines. Remember that the last matching line wins, so order matters, and leading or trailing slashes in patterns are ignored. Excluding the Dockerfile itself does not stop it from being sent, because the builder needs it.

Also add .env, *.pem and similar to every ignore file as a backstop, and replace COPY . . with explicit paths. Treat the leaked .env values as compromised and rotate them.

For shared code that sits outside a service folder, a named build context (--build-context shared=./libs/shared) lets the Dockerfile copy from it like a stage, so you can use the service folder as the main context.

Trade-offs

Allowlists are safe and fast but must be updated when a service starts needing a new path; denylists are easy and leak by default.

Common mistake

Relying on a denylist in a repo where anyone can add a new secret file at any time.

Follow-up

How would you detect in CI that an image contains a file that looks like a secret?

services/api/Dockerfile.dockerignore (allowlist) · text
*
!services/api/
!libs/shared/
!package.json
!package-lock.json
**/.env
**/*.pem
Question 137EasyRuntime

You stopped a container for maintenance on Friday. The host rebooted for patching on Saturday and the container came back on its own, half-migrated. Which restart policy did this, and which should you use?

#

The container was started with --restart always. You ran docker stop before beginning a data migration.

Show answer

With always, a manually stopped container stays stopped only until the Docker daemon restarts or the container is manually restarted. A host reboot restarts the daemon, so the container came back.

unless-stopped is similar to always, except that a container you stopped is not restarted even after the daemon restarts. For long-running services that operators sometimes stop on purpose, unless-stopped matches intent better. on-failure[:max-retries] restarts only on a non-zero exit code, which suits jobs and workers that should stay down after a clean exit. The default is no.

For maintenance work, do not rely on remembering the policy: change it explicitly with docker update --restart no <container> before the work, or remove the container, and restore the policy afterwards.

Trade-offs

always maximises availability after crashes and reboots; unless-stopped respects operator intent at the cost of a container staying down if someone forgets to start it.

Common mistake

Assuming docker stop is remembered across daemon restarts for every policy.

Follow-up

How do restart policies interact with health checks: does Docker restart an unhealthy container?

Make sure it stays down during maintenance · shell
docker update --restart no db-legacy
docker stop db-legacy
Question 138MediumCompose

You set up Compose Watch for fast local development, but file changes never show up in the container and the watcher reports errors. The image runs as a non-root user and is based on a minimal image. What is wrong?

#

The service uses develop.watch with action: sync from ./src to /app/src. The image is a slim runtime image with USER app, and /app is owned by root.

Show answer

Compose Watch's sync action copies changed host files into the running container. For that to work, the image must contain stat, mkdir and rmdir, and the container's USER must be able to write to the target path. A minimal image may lack those binaries, and here /app is owned by root while the process runs as app, so every sync fails.

Fix it in a development target rather than weakening production: a dev stage that includes the basic tools and chowns the app directory to the runtime user, selected in Compose with build.target: dev. Keep the production stage minimal.

Pick the right action per path. sync suits interpreted code with hot reload; sync+restart syncs and restarts the container, which suits config files; rebuild builds a new image with BuildKit and replaces the container, which suits dependency files such as package.json. ignore patterns are relative to the action's path, not the project directory, and .dockerignore rules and .git are ignored automatically. Start it with docker compose up --watch, or docker compose watch to keep build and sync output separate from app logs.

Trade-offs

A separate dev stage keeps production images minimal but means dev and prod images differ slightly, so CI must still test the production target.

Common mistake

Switching the production image to root so the watcher can write.

Follow-up

When is a bind mount still the better choice than Compose Watch?

Sync code, rebuild on dependency changes · yaml
services:
  web:
    build:
      context: .
      target: dev
    develop:
      watch:
        - action: sync
          path: ./src
          target: /app/src
          ignore:
            - "**/*.test.ts"
        - action: rebuild
          path: package.json
Question 139HardSecurity

Why is mounting the Docker socket into a container dangerous?

#

A CI helper container mounts /var/run/docker.sock so it can build images for the pipeline.

Show answer

/var/run/docker.sock is the Docker Engine control API. Anything that can talk to it can create containers, and a new container can bind-mount the host filesystem. That makes socket access effectively root access to the host, even if the helper container itself runs as a non-root user. Docker documentation warns that only trusted users should control the daemon, and that adding a user to the docker group grants root-level privileges.\n\nAn exposed TCP API is worse: port 2375 is unencrypted and unauthenticated by default; 2376 uses TLS. Reachability through a container is enough for privilege escalation, so firewalling other machines does not close the hole.\n\nPrefer not to share the daemon at all. If a container truly needs image builds, use a socket proxy that exposes only the required endpoints, a remote Docker daemon on an isolated host over SSH or mutual TLS, or a daemonless, rootless builder.

Trade-offs

A socket proxy reduces the attack surface but still grants whatever verbs you allow; isolation is weaker than a separate build host.

Common mistake

Treating the socket as a read-only mount or assuming a non-root process inside the container cannot escalate.

Follow-up

How would you give a CI job build capability without any host Docker socket?

Question 140MediumRegistry

What is a pull-through cache or registry mirror?

#

Every CI runner pulls the same base images from Docker Hub, and pulls are slow and rate limited.

Show answer

A registry mirror answers normal docker pull requests from a local cache. On the first pull it fetches the image from Docker Hub and stores it; later pulls are served locally until the cached tag is revalidated. You configure it with --registry-mirror or registry-mirrors in daemon.json, or run a registry with proxy.remoteurl: https://registry-1.docker.io and filesystem storage.\n\nThe scope is limited: only Docker Hub can be mirrored this way, not another private registry, and Docker Hub rate limits still apply to the upstream pulls. If you send credentials to the mirror, the mirror can serve private images visible to that account, so it needs its own authentication. A cluster of caches does not automatically deduplicate concurrent pulls, and aggressive memory limits can cause pulls to be rejected even when an image is cached.\n\nFor a fully controlled supply chain, mirror the images you rely on into your own registry with pinned digests instead of depending on a transparent cache.

Trade-offs

A mirror speeds up common pulls but adds another component that can fail or serve stale content.

Common mistake

Treating a mirror as a private registry or expecting it to bypass Docker Hub rate limits.

Follow-up

What happens when a tag you have cached is retagged upstream?

Question 141MediumRuntime

How does Podman differ from Docker architecturally (daemonless and rootless)?

#

A team wants developers to run containers on shared build machines without granting them docker-group membership.

Show answer

Docker uses a long-running daemon with root privileges; clients talk to it over a socket. Podman has no always-on daemon: each command forks a process, which preserves normal audit attribution for container actions. Its CLI is intentionally Docker-compatible (alias docker=podman), and it uses Buildah internally for images while sharing image storage, not container storage.\n\nPodman can run rootless by mapping the user to a namespace using /etc/subuid and /etc/subgid. A rootless container is not visible to the root Podman instance, and the default cgroup manager is systemd, since cgroupfs does not work rootless. The default OCI runtime is crun, and Quadlet can describe containers, pods, volumes and networks as systemd units.\n\nRootless mode has trade-offs: overlay storage needs kernel 5.12.9 or newer (fuse-overlayfs is the fallback), network device setup uses pasta, and distributed filesystems such as NFS are not supported with rootless overlay storage. The API socket also lives in the user runtime directory rather than the system one.

Trade-offs

Removing the daemon improves the security story but makes some rootful storage and networking setups behave differently.

Common mistake

Claiming Podman needs a daemon, or expecting a rootless container to be visible from the root account.

Follow-up

Why does giving someone docker-group membership effectively give them root on the host?