Practice Docker interview questions with MCQs covering containerization concepts required for DevOps, backend, and platform engineering roles. Topics include the difference between containers and virtual machines, Dockerfiles and image layer caching, multi-stage builds for smaller production images, container networking (bridge, host, overlay, macvlan), volumes and bind mounts for persistent data, Docker Compose for multi-container applications, container registries (Docker Hub, ECR, GCR), health checks, resource limits, and Docker security best practices including non-root users and read-only filesystems. Docker knowledge is now expected at virtually every level in backend and DevOps engineering, teams containerize every service, and interviews routinely include questions on image optimization, container lifecycle management, and Kubernetes integration basics. Difficulty levels range from Trainee (container basics, pull and run commands, basic Dockerfile) through Junior Dev (Dockerfile authoring, volume management, Compose) and Mid Level (multi-stage builds, networking deep-dive, security basics) to Senior Dev (production hardening, image optimization, orchestration concepts). Build real container knowledge, not just quiz answers.
What this Docker quiz covers
Trainee
- Images vs containers
- docker pull, build, stop and logs
- Dockerfile RUN and WORKDIR
- docker inspect and Docker Hub
Junior Developer
- EXPOSE and USER instructions
- docker compose up/down and depends_on
- Volumes and tmpfs mounts
- Tagging images
Mid-Level
- Multi-stage builds and layer ordering
- .dockerignore and pruning dangling images
- Capabilities (--cap-drop) and --pid=host
- Overlay networking and image provenance
Senior
- Running as non-root and keeping images small
- AppArmor, seccomp and gVisor
- containerd and Kubernetes runtime classes
- Image attestation
Sample Docker Interview Questions
Ten representative questions from our full bank of Docker MCQs across all difficulty levels. Each one shows the correct answer and a short explanation. The interactive quiz above shuffles options and tracks your time per question.
- TraineeQ1
Image vs container?
- Image is template; container is running instance Correct
- They are identical objects
- Container builds the image only
- Image is a virtual network
Why: Containers are isolated processes created from images. - TraineeQ2
What does Dockerfile describe?
- How to build a container image step by step Correct
- How to write SQL queries
- The project's Git history
- Cloud infrastructure billing
Why: A Dockerfile contains ordered instructions for creating an image. - TraineeQ3
What does docker ps show by default?
- Currently running containers only Correct
- All locally stored images
- All named volumes
- All configured Docker networks
Why: docker ps lists currently running containers. - TraineeQ4
What does docker pull do?
- Downloads an image from a registry Correct
- Opens a shell in a container
- Deletes a Docker volume
- Builds from a compose file
Why: pull retrieves an image and stores it locally. - Junior DevQ5
What does EXPOSE do?
- Documents the port the container listens on as metadata Correct
- Automatically publishes the port to the host
- Disables the host firewall for that port
- Creates a named volume at that port number
Why: EXPOSE is documentation metadata; actual publishing requires -p flag on docker run. - Junior DevQ6
What does -p 8080:80 mean?
- Host port 8080 maps to container port 80 Correct
- Container port 8080 maps to host port 80
- Two separate containers start sharing a port
- A volume is mounted at path 8080:80
Why: Port mapping syntax is host:container forwarding host traffic to the container. - Junior DevQ7
What is a volume?
- Persistent storage managed outside the container lifecycle Correct
- A CPU resource limit setting
- A container image registry connection
- An image version tag
Why: Volumes preserve data beyond container deletion and can be shared. - Mid LevelQ8
Why use multi-stage builds?
- Produce smaller final images by keeping only needed artifacts from earlier stages Correct
- Allow more port mappings per image
- Generate more verbose build logs
- Always result in slower builds for safety
Why: Build tools stay in earlier stages; the final image copies only the outputs needed. - Mid LevelQ9
What is layer caching?
- Reusing unchanged image build layers to speed up subsequent builds Correct
- Caching DNS resolution inside containers
- A volume-based build artifact backup system
- A runtime in-memory cache for container data
Why: Docker skips rebuilding layers whose instructions and inputs have not changed. - Senior DevQ10
Why avoid running containers as root?
- Limits the blast radius if the container process is exploited or escapes Correct
- Root cannot execute Node.js applications
- It breaks container networking configuration
- Images cannot be built while running as root
Why: Least privilege reduces risk if a container process is compromised.
This is a static preview of 10 questions. Take the full interactive Docker quiz with timed rounds, all 25 questions per level, and instant score tracking.
Frequently Asked Questions: Docker Interviews
Common questions developers ask when preparing for Docker technical interviews.
What Docker concepts are most commonly tested in DevOps and backend interviews?
The difference between containers and virtual machines is almost always tested, interviewers want to verify you understand that containers share the host OS kernel rather than running a full OS. Dockerfile authoring (FROM, RUN, COPY, CMD, ENTRYPOINT), image layer caching, multi-stage builds for optimized production images, volume and bind-mount usage, and Docker Compose for multi-container development setups are all common topics. Container networking and basic security practices come up in mid-to-senior level screenings.
What is the difference between a Docker image and a Docker container?
A Docker image is a read-only, immutable snapshot of a filesystem and configuration, it is the template used to create containers. A container is a running instance of an image, it is the live, isolated process with its own writable layer on top of the image layers. Multiple containers can run from the same image simultaneously without interfering with each other. Images are stored in registries (Docker Hub, ECR); containers run on a Docker host.
What is a multi-stage Docker build and why is it important?
A multi-stage build uses multiple FROM statements in a single Dockerfile, allowing you to use a full build environment (with compilers, test tools, dev dependencies) and then copy only the final artifacts into a minimal runtime image. This produces dramatically smaller production images, a Node.js app might build in a node:18 image but run in a node:18-alpine image, reducing the attack surface and pull time. Multi-stage builds are a standard best practice for production containers.
What is Docker Compose and when should you use it?
Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file (docker-compose.yml). It allows you to declare services, networks, and volumes, then start everything with docker compose up. It is ideal for local development environments (app + database + cache + message queue), integration testing, and simple staging deployments. For production workloads with scaling and self-healing requirements, Kubernetes is the more appropriate tool.
What is the difference between CMD and ENTRYPOINT in a Dockerfile?
ENTRYPOINT defines the executable that always runs when the container starts, it sets the main process and is not easily overridden. CMD provides default arguments to ENTRYPOINT (or acts as the default command if ENTRYPOINT is not set), it can be overridden at docker run time by passing arguments after the image name. The common pattern is ENTRYPOINT ["node"] with CMD ["server.js"], so you can override the script but not accidentally replace the runtime.