‹ Interview

Docker Interview Questions

1 test · 10 questions
Browse all 10 questions ›
Your progress

Study guides

About these Docker questions

Docker comes up in almost every interview for a backend, DevOps, platform or SRE role, usually right after "tell me about a service you deployed". Interviewers rarely ask you to recite flags. They describe something that went wrong, such as a slow build, a container that ignores docker stop, or a service that can't reach its database, and ask what is happening and how you would fix it. These questions are written the same way.

They are not tied to a vendor exam. They are useful as interview preparation, and as the container fundamentals that later material assumes you already know: the Kubernetes certifications (KCNA, CKAD, CKA), cloud container services, and any CI/CD pipeline that builds images. If you can explain why a Dockerfile behaves the way it does, Kubernetes is much easier to pick up.

What the questions cover

  • Images and the build cache. Why instruction order decides how much of a build is reused, how multi-stage builds keep the compiler out of the runtime image, and how a .dockerignore file keeps node_modules, .git and secrets out of the build context.
  • Dockerfile instructions. How ENTRYPOINT and CMD combine with the arguments passed to docker run, and where COPY and ADD behave differently, such as unpacking a local tar archive.
  • The container runtime. What runs as PID 1, why the shell form of ENTRYPOINT swallows SIGTERM, and why that turns every docker stop into a ten-second wait followed by a kill.
  • Storage. Choosing between named volumes, bind mounts and tmpfs, and what each one does with data that is already in the image.
  • Networking. Why containers on the default bridge network can't find each other by name, and what a user-defined network adds.
  • Docker Compose. Making a service wait for a dependency to be healthy, not just started.
  • Images and registries. Why a tag, even a full patch version, can point at different contents over time, and how pinning by digest makes builds repeatable.

How to use them

There is one practice test of 10 questions, mixing easy, medium and hard. Each one explains why the right answer works and why each wrong option doesn't, with a link to the Docker documentation behind it.

  • Answer each question before checking it, and say your reasoning out loud as if to an interviewer. The explanation is where you find out whether the reasoning held up.
  • Reproduce the problem. Most of these scenarios take a few minutes to build with a two-line Dockerfile, and watching the build cache miss or docker stop hang teaches more than reading about it.
  • Read the wrong options closely. Several are things people really do, like --no-cache to fix a slow build or restart: always to paper over a startup race, and knowing why they fall short is what an interviewer is listening for.
  • Keep the Dockerfile reference open. Short sections of it, like the table of how ENTRYPOINT and CMD interact, answer a surprising number of interview questions.

These questions are original, written from the public Docker documentation. They are not taken from any real interview or exam.