COPY

The COPY instruction will copy new files or directories from <source path> and add them to the file system of the container at the path <destination path>.

It's very similar to the ADD instruction, even the syntax is no different:

COPY <source path or URL> <destination path >

The same rules from ADD apply to COPY: all source paths must be relative to the context of the build. Again the presence of the trailing slash at the end of the source and destination path is important: if it's present, the path will be considered a file; otherwise, it will be treated as a directory.

Of course, as in ADD, you can have multiple source paths. If source or destination paths contain spaces, you will need to wrap them in square brackets:

COPY ["<source ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.