Recall & Review
beginner
What does the COPY instruction do in a Dockerfile?
The COPY instruction copies files or directories from the build context on your computer into the Docker image at a specified path.
Click to reveal answer
beginner
How do you copy a single file named
app.py from your local folder to the Docker image's /app directory?Use the instruction: <br>
COPY app.py /app/Click to reveal answer
intermediate
Can the COPY instruction copy multiple files or folders at once?
Yes, you can copy multiple files or folders by listing them separated by spaces before the destination path, for example: <br>
COPY file1.txt file2.txt /app/Click to reveal answer
intermediate
What happens if the destination folder in COPY does not exist inside the image?
Docker will create the destination folder automatically before copying the files.
Click to reveal answer
intermediate
What is the difference between COPY and ADD instructions in Docker?
COPY only copies files and folders from the build context. ADD can also extract compressed files and fetch files from URLs, but COPY is preferred for simple copying because it is more predictable.
Click to reveal answer
Which Dockerfile instruction copies files from your computer into the image?
✗ Incorrect
COPY is used to copy files or directories from your local build context into the Docker image.
What happens if the destination folder in COPY does not exist?
✗ Incorrect
Docker creates the destination folder if it does not exist before copying files.
How do you copy multiple files in one COPY instruction?
✗ Incorrect
You can list multiple files separated by spaces before the destination path in one COPY instruction.
Which instruction is preferred for simple file copying in Dockerfiles?
✗ Incorrect
COPY is preferred for simple copying because it is more predictable and only copies files.
Can COPY fetch files from a URL?
✗ Incorrect
COPY cannot fetch files from URLs; ADD can do that, but COPY only copies local files.
Explain how the COPY instruction works in a Dockerfile and when you would use it.
Think about how you move files into a container image during build.
You got /4 concepts.
Describe the difference between COPY and ADD instructions in Dockerfiles.
Consider extra features ADD has beyond copying.
You got /4 concepts.