liveBook · Manning

Copy instruction

The Dockerfile COPY instruction copies files or directories from a build context or another build stage into an image’s filesystem.

How 2 Manning books explain it

Learn Docker in a Month of Lunches, Second Edition

A COPY instruction is a Dockerfile directive that copies files or directories into the image filesystem.

How it is used
Places application files into Docker images, including source files for builds and compiled artifacts for final stages.
How deep it goes
Defines source and target paths, then works through copy ordering, multi-stage copying, and image-size consequences.
Examples
Uses a Node.js application file, a Maven-built JAR, and a comparison between copying an entire directory and copying only its app folder.
What you can do after
Build it from scratch: write COPY instructions that place needed files in an image while avoiding unnecessary copied content.

Read how Learn Docker in a Month of Lunches, Second Edition explains copy instruction →

Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

The COPY directive adds files, directories, or archive contents from the build host to the image filesystem.

How it is used
Adds build-context content to an image filesystem while constructing a Podman image.
How deep it goes
Explains sources, destinations, rootfs population, and practical builds, but defers detailed path and archive semantics.
Examples
Uses index.html copied into an HTTP server document root and shows the resulting podman build output.
What you can do after
Build it into an image by placing files in a context directory and invoking podman build.

Read how Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more explains copy instruction →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.