liveBook · Manning

Copy instruction

Also called COPY command, COPY directive

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 →

Also covered in

What to know first

Related concepts

Questions about copy instruction

What is copy instruction?

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

Which Manning books explain copy instruction?

Learn Docker in a Month of Lunches, Second Edition and Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more.

What should I know before learning copy instruction?

Manning books that teach copy instruction usually introduce container, package.json and port number first.

What is the difference between copy instruction and ADD?

The Dockerfile COPY instruction copies files or directories from a build context or another build stage into an image’s filesystem. ADD is a Dockerfile instruction that copies files or directories into a container image and can also retrieve files from remote URLs.

What is copy instruction a kind of?

Copy instruction is a kind of instruction. An instruction is a directive specifying an action, operation, task, constraint, or expected behavior for a person or computational system.

What is copy instruction also called?

Copy instruction is also called COPY command or COPY directive.

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.