Dockerfile instructions

Dockerfile COPY

Adds inputs from the context to the image. Relative destinations use WORKDIR; source paths are based on the context root for ordinary local COPY. For multiple sources use a directory destination with trailing slash. Does not establish a live mount. Example requires the note.txt fixture. Compare old and rebuilt images under different tags; excluded context inputs cannot be copied.

Formal Syntax & Structure

docker syntaxdocker
COPY <src> ... <dest>

Parameters & Attributes

NameTypeDescription
srcstringContext file or directory.
deststringDestination in image filesystem.

Working Example

Example Snippetdocker
FROM busybox:1.37WORKDIR /appCOPY note.txt ./note.txtCMD ["cat", "note.txt"]
Docker Reference