ADD
What is ADD?
ADD: Like COPY but with extras: it can fetch remote URLs and auto-extract local tar archives. ADD copies files into a Docker image, like COPY, but with two extras. It can download a file from a URL, and it automatically unpacks local tar archives into the target folder. Those extras are also why Docker's own guidance recommends COPY for normal use. ADD can surprise you: an archive you meant to copy as a file gets unpacked instead. And downloads with ADD give little control over checksums or caching.
Frequently asked questions about ADD
What should you keep in mind with ADD?
Use COPY by default. Reach for ADD only when you deliberately want a local archive unpacked in one step. For downloads, RUN curl with a checksum check, or a multi-stage build, is clearer and safer. Choosing the plainer instruction makes your Dockerfile easier for the next person to read without surprises.
What does an example of ADD look like?
ADD release.tar.gz /opt/app/ At a glance
| Category | Docker |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |