Sitemap

Member-only story

Dockerfile Deep Dive — 3 Interview Questions That Expose Whether You Really Know Docker

8 min readMay 28, 2026

--

Most candidates can write a Dockerfile. Few can explain the subtle decisions behind it. Here’s how a senior engineer answers the questions that reveal true understanding.

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

Interviewer: “You’ve used both COPY and ADD in Dockerfiles. Can you explain the difference and when you’d choose one over the other?”

My answer:

On the surface they look identical — both move files from your host machine into the container image. But ADD does more, and that “more” is actually the reason most experienced engineers avoid it by default.

Let me break it down.

COPY does exactly one thing — it copies files or directories from your build context into the image. Nothing more, nothing hidden, nothing magical.

# Copies source code from your local machine into the image
COPY ./src /app/src
# Copies a specific file
COPY package.json /app/package.json

That’s it. What you see is what you get.

ADD does everything COPY does, plus two extra behaviors:

1. It can fetch files from a remote URL:

# Downloads a file from the internet directly into the image
ADD https://example.com/config/settings.json…

--

--