When would you pick `COPY` over `ADD`?
BeginnerScenarioImage design and Dockerfile decisions
Answer
Situation read → Both copy files; ADD has extra behaviours.
What I'd do → Default to COPY. Use ADD only for auto-extracting a local tar (ADD app.tar.gz /opt/) or for ADD --checksum=sha256:... https://... /file and git URLs.
Why → ADD with remote URLs and silent extraction is surprising and hard to cache or audit. For downloads I prefer curl plus checksum verification in a RUN, or ADD --checksum.
Interview tip → "COPY for intent clarity, ADD for the two cases COPY cannot do."
More on Image design and Dockerfile decisions
A teammate's Node.js image is 1.2 GB. How do you approach shrinking it?BeginnerYou need to run `apt-get install` in a Dockerfile. How do you write it so the layer stays small and cache-safe?BeginnerA service must run a startup script and then the app. Should you use `CMD`, `ENTRYPOINT`, or both?BeginnerYour Docker build re-installs all Python dependencies on every code change. Fix it.BeginnerProduct asks for a container that runs both nginx and a Python app. What do you say?BeginnerYour app ignores `docker stop` and takes exactly 10 seconds to die. Why and what do you change?Intermediate