Docker
/Intermediate
COPY vs ADD
Definition
Instructions used to copy files from the host machine (your laptop) into the Docker image. `COPY` is the standard tool. `ADD` is an older tool that does the same thing but has hidden extra features.
Explain Like I'm New
Taking the source code folder sitting on your Macbook desktop and permanently dragging-and-dropping it inside the Docker Image.
Real World Example
`COPY ./src /app/src`. This copies the 'src' folder from your laptop and pastes it into the '/app/src' directory inside the container.
Common Use Cases
- •Importing source code
- •Injecting configuration files
Interview Questions
basic
- Which command is considered best practice for normal file copying: `COPY` or `ADD`?
intermediate
- What are the 'hidden features' of the `ADD` command?