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 How do you secure Docker containers and images?
Use minimal, regularly rebuilt base images from trusted sources; scan images for vulnerabilities in CI and registries; sign images and verify signatures; run as non-root; drop capabilities…
-
Most asked How do you make Docker images smaller?
Start from a minimal base (slim, Alpine, distroless or scratch for static binaries), use multi-stage builds to leave build tools behind, install only runtime dependencies (--no-install-recommends,…
-
Most asked How do you limit a container's CPU and memory, and what happens when it exceeds them?
Use --memory (and optionally --memory-swap) and --cpus (or CPU shares) with docker run, or deploy.resources.limits in Compose. When a container exceeds its memory limit, the kernel's OOM killer…
-
Most asked How should you tag Docker images, and why is 'latest' a problem?
Tag images with immutable, traceable identifiers such as the Git commit SHA (and optionally a semantic version), and deploy by those tags or by digest. latest is just a default tag name, not 'the…
-
Most asked How do you debug a container that exits immediately or behaves differently in production?
Check the exit code and logs (docker ps -a, docker logs <id>, docker inspect for state and OOMKilled), run it interactively with an overridden entrypoint (docker run -it --entrypoint sh image), and…
-
Most asked How do you run Docker builds in CI pipelines efficiently and safely?
Use BuildKit with remote caching (registry or CI cache) so ephemeral runners reuse layers, build once and push an immutable tag, scan the image, sign it, and deploy that exact digest to every…
-
What should you consider when choosing a base image?
Security and maintenance (an official or vendor-maintained image with timely patches), size, compatibility (glibc versus musl; required system libraries), and how much tooling you need at runtime.…
-
How do you run a database in Docker for local development, and should you do it in production?
For development, run the database image with a named volume for its data, a health check, and initialisation scripts or migrations; Compose makes this easy. In production, a managed database service…
-
How do you speed up a slow Docker build?
Measure which steps are slow (docker build --progress=plain), then: order instructions so dependency installation is cached, shrink the build context with .dockerignore, use BuildKit cache mounts…
-
How do you clean up disk space used by Docker?
Check usage with docker system df, then remove what is unused: stopped containers (docker container prune), dangling or unused images (docker image prune or -a), unused volumes (docker volume prune,…
-
How do you run multiple processes in one container, and should you?
The convention is one main concern per container: easier scaling, logging, health checks and restarts. If you genuinely need several processes (for example a legacy app with a helper), use a minimal…