LearnDevOpsHands-On Labs
Back to All Interview Tracks
28 QuestionsDevOps & Cloud

Docker Interview Questions

28 Docker questions from real interviews, sorted by seniority: images and layers, networking, volumes, Compose, security and multi-stage builds.

Images & ContainersLayer CachingVolumes vs Bind MountsMulti-stage BuildsComposeSecurity
Showing 28 of 28 questions
•
#1

What is the difference between an image and a container?

Junior
ImageContainer
What it isA read-only templateA running instance of one
FilesystemStacked layers, immutableThose layers plus a thin writable layer
LifecycleBuilt once, reusedCreated, started, stopped, removed
AnalogyA classAn object

One image can back a hundred containers, and each gets its own writable layer, so writes inside one are invisible to the others.

The consequence worth stating out loud: anything written inside a container is lost on docker rm unless it was written to a volume or a bind mount. That is what interviewers are checking you understand.

link
#2

How is a container different from a virtual machine?

#3

What happens when you run <code class="rounded-none bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] text-slate-900">docker run nginx</code>?

#4

What is a Docker layer, and why does layer order matter?

#5

What is the difference between COPY and ADD in a Dockerfile?

#6

How do you persist data from a container?

#7

What is a multi-stage Docker build, and what problem does it solve?

#8

What is the difference between CMD and ENTRYPOINT in Docker?

#9

Explain Docker's default network drivers and when you would use each.

#10

Two containers are on the same host but cannot reach each other. How do you debug it?

#11

What is the difference between a Docker named volume and a bind mount?

#12

What does <code class="rounded-none bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] text-slate-900">depends_on</code> actually guarantee in Docker Compose?

#13

How do you make a Docker image smaller?

#14

A container exits immediately after starting. How do you find out why?

#15

Why should a container not run as root, and how do you avoid it?

#16

How do you get a secret into an image without leaking it?

#17

What is the problem with the Docker <code class="rounded-none bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] text-slate-900">latest</code> tag?

#18

How does the Docker build cache decide whether a layer can be reused?

#19

Your image works locally on an M-series Mac and fails on the cluster with "exec format error". What happened?

#20

Which Linux primitives actually provide container isolation?

#21

Why does your container take ten seconds to stop, and how do you fix it?

#22

How do you handle logging for containers, and why not write to a file?

#23

What is a healthcheck, and where does Docker's version not apply?

#24

How would you secure a container supply chain end to end?

#25

<code class="rounded-none bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] text-slate-900">docker system df</code> shows 40 GB reclaimable. Walk through cleaning it up safely.

#26

Where does Docker Compose stop being the right tool?

#27

How do you debug inside a container that has no shell?

#28

What does <code class="rounded-none bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] text-slate-900">.dockerignore</code> do, and why does it matter?