Skip to main content

Why do production Dockerfiles avoid using ADD?

Junior Docker
Quick Answer ADD can accept remote URLs and auto-extracts tarballs รขโ‚ฌโ€ which sounds useful but adds implicit behavior and is a security risk (fetching from remote URLs during build). COPY is explicit รขโ‚ฌโ€ it only copies files from the local build context. Prefer COPY; use ADD only when you specifically need tarball extraction.

Answer

ADD auto-extracts archives and supports remote URLs, causing unpredictable builds. COPY is preferred unless extraction is needed.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice