DELAPARRA
Index
Color
NL
Category: Docker

COPY

Explained by Updated

What is COPY?

COPY: Copies files/directories from the build context into the image. The plain, predictable way to add your source code. COPY copies files and folders from the build context into a Docker image. It is the plain, predictable way to add your code, such as COPY src ./src. The order of COPY lines has a big effect on build speed. Docker caches each step, and a step is rebuilt when the files it copies change. Copy dependency files first, install dependencies, then copy the rest of the code. Then editing a source file does not trigger a full reinstall of every package.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about COPY

What should you keep in mind with COPY?

Pair it with a .dockerignore file that excludes .git, node_modules, vendor, local .env files and logs. That keeps images small and secrets out of them. Use --chown to set ownership during the copy instead of running a separate chown step, which would add another large layer to the image.

What does an example of COPY look like?

COPY package*.json ./ COPY src ./src

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.