COPY copies from the build context or another stage; ADD can also fetch URLs and unpack archives
Answer: The COPY instruction copies new files or directories from <src> into the image at <dest>. Sources can come from the build context, a build stage, a named context, or an image. The ADD instruction also copies sources into the image, but those sources can come from the build context, a remote URL, or a Git repository.
How they differ
ADD and COPY are functionally similar, but they serve slightly different purposes. Prefer COPY when you are only copying local files from the context. Use COPY --from to copy from a named build stage, context, or image.
Both instructions have a JSON-array form that is required when a path contains whitespace. The last argument is always the destination. If you specify multiple sources, the destination must be a directory and must end with a slash.
See also
Claims
- id: C1 claim: COPY copies new files from a source into the image at dest. source: S1 evidence: "COPY instruction copies new files"
- id: C2 claim: ADD and COPY are similar but serve slightly different purposes. source: S1 evidence: "functionally similar, but serve slightly different purposes"
- id: C3 claim: ADD can copy from the build context, a remote URL, or a Git repository. source: S2 evidence: "can be copied from the build context, a remote URL, or a Git repository"
- id: C4 claim: COPY can copy from the build context, a build stage, a named context, or an image. source: S2 evidence: "can be copied from the build context, build stage, named context, or an image"
Sources
- [S1] Dockerfile reference (COPY and ADD). Docker docs. https://docs.docker.com/reference/dockerfile/ . License: Apache-2.0. Accessed 2026-11-17.
- [S2] Dockerfile reference (docs source, COPY and ADD). docker/docs (GitHub). https://github.com/docker/docs/blob/main/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md . License: Apache-2.0. Accessed 2026-11-17.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, Dockerfile reference (COPY and ADD), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE); docker/docs (GitHub), Dockerfile reference (docs source, COPY and ADD), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs, Dockerfile reference (COPY and ADD), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE); docker/docs (GitHub), Dockerfile reference (docs source, COPY and ADD), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE).
Cite this
iinventedlight. 2026. "COPY copies from the build context or another stage; ADD can also fetch URLs and unpack archives." iinventedlight Library, iil:note:vmd1d180, version of 2026-11-17. https://iinventedlight.com/library/notes/docker-copy-and-add/. License: CC-BY-4.0.
@misc{iil_note_vmd1d180,
author = {{iinventedlight}},
title = {{COPY copies from the build context or another stage; ADD can also fetch URLs and unpack archives}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-17},
url = {https://iinventedlight.com/library/notes/docker-copy-and-add/},
note = {Permanent ID iil:note:vmd1d180. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-copy-and-add.md.