← All notes

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

Sources

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

Permanent ID: iil:note:vmd1d180

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.},
}

Markdown

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.