Copy instruction
The Dockerfile COPY instruction copies files or directories from a build context or another build stage into an image’s filesystem.
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.
Related concepts
- file systemuses · A file system is a software-managed structure and interface for organizing, naming, storing, and accessing files and directories on storage.
- Dockerfileused by · A Dockerfile is a text file containing declarative instructions for building a container image and specifying its contents and runtime metadata.
- context directoryuses · A context directory is a directory containing the files and build instructions made available to a container image build.
- container imageuses · A container image is a packaged filesystem and configuration artifact from which a container can be created and run.
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.

