beginnerDockerfile Instructions & Multi-Stage Builds
What is the difference between COPY and ADD?
COPY does a literal, predictable file/directory copy from the build context into the image. ADD does everything COPY does, plus two extra behaviors: it can download a file from a remote URL, and it automatically extracts recognized local archive formats (tar, gzip) into the destination. Best practice is to prefer COPY unless you specifically need one of ADD's extra behaviors.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response