Interview Q&A · questions with model answers
Docker Interview Questions
Part of the study plan for: DevOps Engineer · Site Reliability Engineer (SRE) · Cloud Engineer · Backend Engineer · Full Stack Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked What are multi-stage builds, and why use them?
A multi-stage Dockerfile has several FROM stages: build tools and dependencies live in earlier stages, and the final stage copies only the built artifacts (COPY --from=build ...) into a small…
-
Most asked What are Dockerfile best practices for production images?
Use a small, trusted, pinned base image; use multi-stage builds; order instructions for caching; combine package installs with cleanup in one layer; use a .dockerignore; run as a non-root user; use…
-
Most asked What is Docker Compose used for, and how do you handle service start-up order?
Compose defines multi-container applications in a YAML file (compose.yaml): services, images or builds, ports, volumes, networks, environment and dependencies, and starts them together with docker…
-
Most asked What is a software supply chain attack on containers, and how do you defend against it?
An attacker compromises something you build from rather than your code directly: a malicious or typo-squatted base image, a compromised dependency, a tampered CI pipeline, or a pushed image replaced…
-
What is BuildKit, and what does docker buildx add?
BuildKit is Docker's modern build engine (the default builder): it builds independent stages in parallel, skips unused stages, supports cache mounts, secret and SSH mounts, better caching (including…
-
What does HEALTHCHECK do in a Dockerfile, and do orchestrators use it?
HEALTHCHECK defines a command Docker runs periodically inside the container; the container's status becomes healthy or unhealthy. Docker itself does not restart unhealthy containers (Swarm does),…
-
What is the OCI, and how do Docker, containerd, runc and Podman relate?
The Open Container Initiative defines standard image and runtime specifications. Docker builds OCI-compatible images; containerd is a container runtime daemon (used by Docker Engine and by…
-
What is the Docker build context, and why does it matter?
The build context is the set of files sent to the builder (usually the directory passed to docker build, such as .). Only files in the context can be copied into the image, and a large context slows…
-
What is Docker Swarm, and why do most teams use Kubernetes or managed services instead?
Swarm mode is Docker's built-in orchestrator: services with replicas, rolling updates, overlay networking, secrets and a simple setup using the familiar Compose format. It is easy to learn but has a…
-
What are rootless Docker and user namespaces?
Rootless mode runs the Docker daemon and containers as an unprivileged user, so even a container escape lands as that user rather than root on the host. User namespace remapping (userns-remap) maps…
-
What changed with Docker Desktop licensing, and what are the alternatives?
Docker Desktop requires a paid subscription for commercial use in larger organisations (above set employee and revenue thresholds), while remaining free for small businesses, personal use, education…