OctogleHire
← Interview questions library

25 Docker interview questions

Structure the Docker interview loop around the work the engineer will actually own. Start with a short screening conversation to confirm recent hands-on use of Docker Engine, Compose v2, BuildKit/buildx, registries, and Linux fundamentals. Follow with a debugging interview using logs, Dockerfile snippets, image history, networking symptoms, and CI failures. Add a practical exercise that tests image quality, reproducibility, security, and developer experience, not memorized flags. For mid and senior candidates, include a design round covering build pipelines, runtime isolation, supply-chain controls, and migration trade-offs. Close with a collaboration round: incident communication, documentation habits, platform empathy, and how they make safe changes across teams.

Junior Docker questions

Fundamentals, learning speed and how they debug.

  1. 01A developer says, “It works on my laptop, but not in Docker.” How would you narrow down whether the problem is the image, the container runtime configuration, or the application itself?

    Listen for: A strong answer starts by reproducing the exact command or Compose service, checking image tag and build context, then comparing environment variables, mounted files, working directory, user, exposed ports, and startup command. They should use docker logs, docker inspect, docker exec, and minimal changes to isolate one variable at a time.

    Red flag: They immediately rebuild everything or change the application code without first comparing container configuration to the local environment.

  2. 02You inherit a Dockerfile that uses ubuntu:latest, installs packages, copies source, and runs the app as root. What would you improve first and why?

    Listen for: Look for practical prioritization: pin a maintained base image, reduce layers where useful, separate dependency install from source copy for cache reuse, add a non-root user, remove build-only tools from the final image, and use .dockerignore. They should explain trade-offs, not just say “use Alpine” for every workload.

    Red flag: They focus only on image size and ignore security, reproducibility, and cache behavior.

  3. 03A Compose service can connect to Postgres from the host, but another container gets connection refused. What do you check?

    Listen for: They should understand that localhost inside a container is the container itself, not the host or another service. Good signals include checking service names on the Compose network, container health, port versus expose, startup ordering versus readiness, logs, network aliases, and whether Postgres is bound to the right interface.

    Red flag: They suggest using the host machine’s public IP as the default fix for container-to-container communication.

  4. 04How do you decide what goes into .dockerignore, and what problems can a bad .dockerignore cause?

    Listen for: A solid answer mentions excluding node_modules, .git, local build artifacts, secrets, test outputs, caches, and large generated files unless intentionally needed. They should connect this to build speed, cache invalidation, accidental secret leakage, non-reproducible builds, and remote BuildKit builders receiving unnecessary context.

    Red flag: They think .dockerignore is only a cosmetic cleanup file and has no effect on security or build performance.

  5. 05A container exits immediately in CI, but stays running locally. What information would you collect before changing the Dockerfile?

    Listen for: They should collect the exact image digest or tag, docker run or Compose command, entrypoint and command, environment differences, CI runner architecture, logs, exit code, working directory, mounted files, permissions, and resource limits. Good candidates check whether CI overrides the command or runs without expected secrets.

    Red flag: They assume CI is broken and cannot name specific runtime differences to inspect.

  6. 06What is the difference between publishing a port and exposing a port, and when does it matter?

    Listen for: They should explain that EXPOSE is image metadata and documentation for intended listening ports, while -p or Compose ports publishes a container port to the host. It matters for host access, local development, test runners, service discovery assumptions, and avoiding accidental exposure of internal-only services.

    Red flag: They believe EXPOSE alone makes a service reachable from the host or the internet.

Mid-level Docker questions

Independent delivery, trade-offs and code quality.

  1. 07You need to speed up a slow Docker build in GitHub Actions or GitLab CI. What changes would you make before adding bigger runners?

    Listen for: Strong answers discuss BuildKit/buildx cache mounts, registry-backed cache, ordering Dockerfile layers for dependency reuse, splitting dependency and source copy steps, .dockerignore, multi-stage builds, pinned base images, and avoiding unnecessary apt updates. They should mention measuring build steps and cache hit rates rather than guessing.

    Red flag: They only suggest adding more CPU or using a smaller base image without analyzing cache misses.

  2. 08How would you build and publish linux/amd64 and linux/arm64 images reliably?

    Listen for: Listen for buildx with a named builder, platform-specific testing, QEMU versus native builders, avoiding architecture-specific package assumptions, publishing a multi-arch manifest, and pinning base images that support both platforms. They should discuss verifying with docker buildx imagetools inspect and running smoke tests per architecture.

    Red flag: They assume a single local docker build automatically creates a correct multi-architecture image.

  3. 09A production image scan reports critical vulnerabilities in the base image, but the app team says the container is internal-only. How do you respond?

    Listen for: A mature answer separates exploitability from policy. They would inspect affected packages, whether vulnerable code is reachable, fixed base tags, rebuild freshness, distro security status, and compensating controls. They should propose a time-bound remediation path and avoid both panic upgrades and blanket dismissal.

    Red flag: They say internal containers do not need patching or scanning.

  4. 10What are the trade-offs between bind mounts, named volumes, and baking files into an image?

    Listen for: Good candidates distinguish development convenience from production reproducibility. Bind mounts are flexible but host-dependent and permission-prone; named volumes suit durable container-managed data; baked files improve immutable deployments and repeatability. They should mention backup, ownership, SELinux/AppArmor contexts, portability, and how mounts can hide image contents.

    Red flag: They recommend bind mounts for all persistent data in every environment.

  5. 11A Dockerized service writes files as root, causing permission problems on the host. How would you fix it without making the container less secure?

    Listen for: They should discuss running as a non-root user, setting UID/GID deliberately, using COPY --chown, adjusting volume ownership in an entrypoint only when necessary, and documenting local development UID mapping. Stronger answers mention user namespaces, rootless Docker, and avoiding chmod 777 as a shortcut.

    Red flag: They solve it by running everything as privileged or recursively chmodding mounted directories to 777.

  6. 12How do you make Docker image builds more reproducible?

    Listen for: Look for pinned base image digests when appropriate, locked language dependencies, deterministic build arguments, avoiding latest, controlled package repositories, BuildKit provenance/SBOM where useful, and a clear rebuild process. They should understand that reproducibility includes inputs, architecture, build environment, and registry immutability.

    Red flag: They claim Docker builds are automatically reproducible because the Dockerfile is committed.

  7. 13A team wants one Compose file for local development, CI integration tests, and staging. What would you recommend?

    Listen for: A good answer uses a base Compose file plus override files or profiles, with clear environment-specific configuration and minimal duplication. They should avoid leaking production secrets into local config, distinguish build versus image references, use healthchecks for dependencies, and keep CI deterministic.

    Red flag: They put every environment difference into one large Compose file with many conditional workarounds.

Senior Docker questions

Judgement, architecture and raising the team's bar.

  1. 14You are asked to standardize Dockerfiles across many repositories. What standards do you set, and where do you allow exceptions?

    Listen for: Strong answers define defaults for base images, non-root runtime users, healthchecks where useful, BuildKit syntax, multi-stage structure, labels, SBOM/provenance, .dockerignore, vulnerability handling, and image tagging. They allow exceptions based on runtime requirements, compliance, performance, and supportability, with documented review rather than rigid templates.

    Red flag: They propose one universal Dockerfile template for every language and workload.

  2. 15A registry tag was overwritten and a deployment pulled an unexpected image. How would you prevent a repeat?

    Listen for: They should discuss immutable tags or registry policies, deploying by digest, signed images with Cosign or Notation where appropriate, CI-controlled promotion, audit trails, retention policy, and separating build tags from release tags. Good answers include detection and rollback, not just prevention.

    Red flag: They rely on developers remembering not to push the same tag again.

  3. 16How would you reduce the blast radius of Docker daemon access on shared CI runners?

    Listen for: Listen for avoiding raw docker.sock exposure, using rootless BuildKit/buildx, isolated runners, least-privilege credentials, short-lived registry tokens, network restrictions, user namespaces, and ephemeral build environments. They should know docker.sock is effectively host-root access and design workflows around that risk.

    Red flag: They mount /var/run/docker.sock into arbitrary build containers and call it secure because the container is non-root.

  4. 17A company is moving from Docker Compose deployments on VMs to Kubernetes, but developers still use Docker locally. What migration guidance would you give?

    Listen for: A strong answer separates local developer workflow from production orchestration. They preserve Compose for fast local feedback where it fits, align images, health endpoints, configuration, and graceful shutdown behavior, and avoid pretending Compose maps one-to-one to Kubernetes. They also plan documentation, CI tests, and phased service migration.

    Red flag: They insist Docker Compose must be eliminated immediately or that Kubernetes YAML can be generated blindly from Compose.

  5. 18How do you handle secrets during Docker builds and runtime?

    Listen for: They should mention BuildKit secrets and SSH mounts for build-time access, avoiding ARG/ENV for secrets, checking image history, using runtime secret stores or orchestrator-managed secrets, limiting file permissions, and rotating exposed credentials. Good answers include scanning and incident response for leaked secrets.

    Red flag: They pass tokens as build args and assume multi-stage builds always remove the risk.

  6. 19A Docker host shows high disk usage and production containers are at risk. How do you investigate safely?

    Listen for: They should inspect docker system df, images, containers, volumes, BuildKit cache, logs, overlay2 usage, and application data before pruning. Strong candidates protect named volumes and running containers, coordinate change windows if needed, adjust log rotation, and fix retention policies rather than running broad prune commands blindly.

    Red flag: They immediately run docker system prune -a --volumes on a production host.

  7. 20How would you design an image lifecycle policy from build to retirement?

    Listen for: Good answers include ownership labels, versioning and digest tracking, vulnerability scanning gates, SBOM/provenance artifacts, promotion between environments, signature verification, retention rules, rollback availability, end-of-life handling for base images, and rebuild cadence. They should balance governance with developer usability and automation.

    Red flag: They only define naming conventions and ignore patching, promotion, and deprecation.

System design Docker questions

Designing real systems end to end.

  1. 21Design a Docker-based build platform for 60 repositories using different languages, with fast builds and consistent security controls.

    Listen for: Look for centralized but flexible build standards: BuildKit/buildx builders, registry cache, language-specific templates, secret handling, SBOM/provenance, image signing, vulnerability gates, and clear ownership. Strong candidates discuss self-service developer experience, exception handling, metrics from build logs, and avoiding a brittle one-size-fits-all pipeline.

    Red flag: They design a single monolithic pipeline that every repository must use exactly the same way.

  2. 22Design a secure local development environment using Docker Compose for a microservice team with databases, queues, and mock external APIs.

    Listen for: Strong answers cover Compose profiles, project naming, isolated networks, named volumes for stateful services, seed data, healthchecks, predictable ports, non-root containers, secret handling for local-only values, and easy reset commands. They should prioritize fast onboarding while preventing accidental calls to real production services.

    Red flag: They mount production credentials into local containers to make development realistic.

  3. 23Design a multi-architecture image publishing process for a product that supports both Intel cloud hosts and ARM developer laptops.

    Listen for: They should propose buildx, native or emulated builders, per-platform tests, dependency validation, manifest list publication, digest-based deployment, and clear tag strategy. Good answers include handling platform-specific bugs, base image compatibility, caching per architecture, and rollback if one architecture fails validation.

    Red flag: They publish one tag after testing only on the engineer’s laptop.

  4. 24Design a Docker image supply-chain control model for a regulated product team.

    Listen for: A strong answer includes approved base images, locked dependencies, SBOM generation, provenance attestations, vulnerability scanning with documented risk acceptance, image signing, registry access control, immutable promotion, audit logs, and emergency patch flow. They should keep controls automated in CI and avoid blocking teams with manual ticket-heavy steps.

    Red flag: They rely mainly on a spreadsheet of approved images maintained by hand.

  5. 25Design an approach for running containerized workloads on shared VM hosts where some workloads are less trusted than others.

    Listen for: Listen for isolation boundaries: separate hosts or pools for trust levels, rootless Docker where feasible, user namespaces, read-only filesystems, dropped capabilities, seccomp/AppArmor/SELinux profiles, resource limits, network segmentation, logging, and restricted daemon access. Strong answers recognize Docker is not a hard multi-tenant security boundary by default.

    Red flag: They run all workloads on the same Docker daemon and depend only on container names for separation.

Practical task · 2–3 hours

Harden and Debug a Dockerized Service

Provide a small web service repository with a flawed Dockerfile, a Compose file for an app plus Postgres, and a failing CI build log. Ask the candidate to make the image production-ready and developer-friendly: fix the build, improve caching, run as non-root, reduce unnecessary contents, add a useful healthcheck, correct networking or readiness issues, and document how to build, run, test, and troubleshoot it. They may use Docker Engine 28.x, Compose v2, and BuildKit/buildx. The deliverable is a pull request or patch plus a short explanation of trade-offs and remaining risks.

How to evaluate it

  • Dockerfile quality: layering, cache behavior, pinned inputs, multi-stage use, and sensible base image choice.
  • Runtime safety: non-root execution, permissions, minimal privileges, secret handling, and no broad insecure shortcuts.
  • Debugging approach: identifies the actual failing condition using logs, inspect output, networking checks, and exit codes.
  • Developer experience: clear Compose workflow, health/readiness handling, reset instructions, and readable documentation.
  • Judgment: explains trade-offs, avoids over-engineering, and leaves a maintainable result.

Rather skip the interview loop?

Every Octogle Docker engineer has already passed a technical assessment, system design and a live interview with an engineer who has shipped Docker. Send a brief and get 3–5 scored profiles in 48 hours.