Difference between 'COPY' and 'ADD' in a Dockerfile.

Updated Apr 28, 2026

Short answer

COPY is for basic file copying; ADD has extra features like remote URL support and automatic tar extraction.

Deep explanation

Modern Docker workflows focus on optimization. Multi-stage builds allow you to use a heavy build environment (with compilers and tools) but only copy the final binary into a slim production image (like Alpine).

Real-world example

Running a WordPress site with separate containers for PHP-FPM, Nginx, and MySQL locally.

Common mistakes

  • Storing sensitive passwords in plain text within the Dockerfile or environment variables.

Follow-up questions

  • How does Docker networking work by default?

More Docker interview questions

View all →