1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [COPY](<https://delaparra-services.nl/knowledge-hub/copy>)

  

Category: Docker 

# COPY

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## 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](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/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[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More Docker terms

 

- [CMD](<https://delaparra-services.nl/knowledge-hub/cmd>) 
- [container](<https://delaparra-services.nl/knowledge-hub/container>) 
- [container DNS](<https://delaparra-services.nl/knowledge-hub/container-dns>) 
- [depends\_on](<https://delaparra-services.nl/knowledge-hub/depends-on>) 
- [digest](<https://delaparra-services.nl/knowledge-hub/digest>) 
- [Docker Hub](<https://delaparra-services.nl/knowledge-hub/docker-hub>)

 

[All terms starting with C](<https://delaparra-services.nl/knowledge-hub#letter-c>)

 

## Skills

 

- ### Docker Build Strategies

 

Use this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization.

 [View skill](<https://delaparra-services.nl/skills/docker-build-strategies>) [Download zip](<https://delaparra-services.nl/skills/docker-build-strategies/download>) 
- ### Multi Stage Dockerfile

 

'Create optimized multi-stage Dockerfiles for any language or framework'

 [View skill](<https://delaparra-services.nl/skills/multi-stage-dockerfile>) [Download zip](<https://delaparra-services.nl/skills/multi-stage-dockerfile/download>) 
- ### Docker Project Foundations

 

Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database or cache dependency, or running services without host-level installs. Covers Dockerfile, compose.yaml, and .dockerignore creation with Docker best practices.

 [View skill](<https://delaparra-services.nl/skills/docker-project-foundations>) [Download zip](<https://delaparra-services.nl/skills/docker-project-foundations/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/copy/skills.zip>)

 

## Manuals

 

- [Docker for your Laravel app](<https://delaparra-services.nl/manuals/docker-voor-je-laravel-app>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.

 

## 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.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/copy)
