Docker Interview Questions: 30 Questions With Answers for Freshers and Experienced (2026)

Docker Interview Questions: 30 Questions With Answers for Freshers and Experienced (2026)

Last updated: November 2026

Docker is now a basic skill for backend, DevOps and cloud roles. It is used by 71.1% of developers in the Stack Overflow Developer Survey 2025, a jump of 17 percentage points from 2024 according to Stack Overflow's announcement. So expect Docker questions even in developer interviews, not just DevOps ones.

Here are 30 Docker questions, from basics to real-world debugging, each with a short answer.

What gets asked most: image vs container, Docker vs virtual machine, Dockerfile instructions (CMD vs ENTRYPOINT, COPY vs ADD), volumes, networking, Docker Compose, multi-stage builds and how to make images smaller and safer.

Basics

1. What is Docker?

A tool that packages an application with everything it needs (code, runtime, libraries) into a container, so it runs the same on a laptop, a test server and production.

2. What is a container?

A running, isolated process with its own file system, network and limits, sharing the host's kernel. It starts in seconds because there is no full operating system to boot.

3. Image vs container?

An image is a read-only template, like a recipe. A container is a running instance of that image, like the dish. One image can start many containers.

4. Docker vs virtual machine?

ContainerVirtual machine
Operating systemShares the host kernelFull guest OS for each VM
SizeMegabytesGigabytes
Start timeSecondsMinutes
IsolationProcess-levelStronger, hardware-level

5. What is a Dockerfile?

A text file with step-by-step instructions to build an image: which base image to start from, which files to copy, which commands to run and how to start the app.

6. What is Docker Hub or a registry?

A place to store and share images. Docker Hub is the public default; companies also use private registries such as Amazon ECR or Azure Container Registry.

7. Name the main Docker commands.

docker build, docker run, docker ps, docker images, docker logs, docker exec, docker stop, docker rm, docker pull and docker push.

8. What is the Docker daemon?

The background service (dockerd) that builds images and runs containers. The docker command you type is a client that talks to it.

Dockerfile questions

9. CMD vs ENTRYPOINT?

ENTRYPOINT sets the main command that always runs. CMD sets default arguments or a default command that can be overridden at docker run. A common pattern: ENTRYPOINT is the program, CMD holds its default flags.

10. COPY vs ADD?

Both copy files into the image. ADD can also unpack local tar files and fetch URLs. Prefer COPY because it is simpler and more predictable.

11. RUN vs CMD?

RUN executes during the build and creates a new image layer, for example installing packages. CMD runs when the container starts.

12. What are image layers?

Each instruction such as RUN or COPY creates a layer. Layers are cached and shared between images, which makes builds and downloads faster.

13. How do you make builds faster using the cache?

Put rarely changing steps first. For example, copy package.json and install dependencies before copying the rest of the code. Then a code change does not reinstall every package.

14. What is a multi-stage build?

A Dockerfile with more than one FROM. You build in a heavy image with compilers, then copy only the final output into a small runtime image. The result is smaller and safer.

15. How do you reduce image size?

Use a slim or minimal base image, multi-stage builds, a .dockerignore file, fewer layers by combining RUN steps, and clean up package caches in the same step that creates them.

16. What is .dockerignore?

A file listing what not to send to the build, such as node_modules, .git and secrets. It speeds up builds and keeps junk and secrets out of images.

Storage and networking

17. Volumes vs bind mounts?

A volume is storage managed by Docker and is the preferred way to keep data, such as a database's files. A bind mount maps a specific folder on the host into the container, useful for local development.

18. What happens to data when a container is removed?

Data written inside the container's own layer is lost. Data in a volume stays and can be attached to a new container.

19. What are Docker network types?

Bridge (default, containers on one host talk to each other), host (container uses the host's network directly), none (no network) and overlay (containers across several hosts).

20. How do two containers talk to each other?

Put them on the same user-defined bridge network. They can then reach each other by container name, for example the app connects to db:5432.

21. What does -p 8080:80 mean?

It maps port 8080 on the host to port 80 inside the container, so you open localhost:8080 to reach the app.

Docker Compose and orchestration

22. What is Docker Compose?

A tool to define and run multi-container apps from one YAML file. One command, docker compose up, starts the app, database and cache together.

23. What does depends_on do?

It controls start order in Compose. It does not wait for a service to be ready unless you add a health check condition.

24. Docker vs Kubernetes?

Docker builds and runs containers. Kubernetes runs and manages many containers across many machines: scaling, restarts, rolling updates and service discovery. See our Kubernetes interview questions.

Security and production

25. How do you keep secrets out of images?

Never put secrets in the Dockerfile or image. Pass them at runtime through environment variables from a secret manager, Docker secrets or Kubernetes secrets, and use build secrets for build-time needs.

26. Why run containers as a non-root user?

If the app is attacked, a non-root user limits the damage. Add a USER instruction in the Dockerfile.

27. What is a health check?

A command Docker runs to test whether the app inside is working, for example calling a /health URL. Orchestrators use it to restart unhealthy containers.

28. How do you limit CPU and memory?

Use flags such as --memory=512m and --cpus=1. Limits stop one container from starving others on the same host.

Debugging scenarios

29. A container exits right after starting. What do you check?

  1. docker logs for the error
  2. docker ps -a for the exit code
  3. Whether the main process runs in the foreground (a container stops when its main process ends)
  4. Missing environment variables or a wrong CMD

30. The app works locally but not in a container. Why?

Common causes: the app listens on localhost instead of 0.0.0.0, a missing port mapping, files left out by .dockerignore, a different base image version, or a config file that exists only on your laptop.

How to prepare

  • Containerise one real app. A small API plus a database in Docker Compose answers half these questions from experience.
  • Know the "why" behind each step. Interviewers ask why you chose a slim image or a multi-stage build.
  • Revise Linux and networking basics with our Linux interview questions.
  • See the bigger picture in our DevOps roadmap and DevOps interview questions.

Curious what DevOps roles pay? The DevOps engineer salary guide breaks it down by experience.

Ready to apply?

See open DevOps engineer roles on Weekday at startups, product companies and GCCs, with filters for experience and city.

See DevOps engineer jobs →

Frequently asked questions

What is the difference between a Docker image and a container?

An image is a read-only template. A container is a running instance of that image. One image can start many containers.

What is the difference between CMD and ENTRYPOINT?

ENTRYPOINT sets the main command that always runs. CMD sets default arguments or a default command that can be overridden when you run the container.

How is Docker different from a virtual machine?

Containers share the host's kernel, so they are smaller and start in seconds. Virtual machines run a full guest operating system each, which gives stronger isolation but uses more resources.

What is a multi-stage build in Docker?

A Dockerfile with several stages: build in a large image, then copy only the output into a small runtime image. It makes images smaller and safer.

Is Docker needed for developers, or only DevOps?

Both. Docker is used by 71.1% of developers in the Stack Overflow 2025 survey, so many developer interviews include a few Docker questions.

Latest Articles

Browse Articles
Use AI to find jobs and apply

Stop manually filling job applications. Use AI to auto-apply to jobs

Browse jobs now