Challenge - 5 Problems
COPY Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the result of this Dockerfile COPY command?
Given this Dockerfile snippet:
What happens when you build this Docker image?
FROM alpine COPY ./app /usr/src/app
What happens when you build this Docker image?
Docker
FROM alpine COPY ./app /usr/src/app
Attempts:
2 left
💡 Hint
COPY copies files or folders from your computer into the image.
✗ Incorrect
COPY copies the local folder named 'app' into the image at the specified path. The source path './app' is a folder, so the entire folder is copied.
🧠 Conceptual
intermediate1:30remaining
Understanding relative paths in COPY instruction
In a Dockerfile, what does the source path in COPY refer to?
Attempts:
2 left
💡 Hint
Think about where Docker looks for files when building.
✗ Incorrect
The source path in COPY is relative to the build context, which is the folder you specify when running 'docker build'.
❓ Configuration
advanced2:00remaining
Which COPY command correctly copies multiple files?
You want to copy two files, 'index.html' and 'style.css', from your local folder into '/usr/share/nginx/html' inside the image. Which COPY command is correct?
Attempts:
2 left
💡 Hint
COPY can take multiple source files followed by one destination folder.
✗ Incorrect
Options A and B correctly copy multiple source files to the destination directory (A uses space-separated syntax, B uses JSON array form). Options C and D have wrong order or paths.
❓ Troubleshoot
advanced2:30remaining
Why does this COPY command fail during build?
Dockerfile snippet:
When building, you get an error: 'COPY failed: stat /var/lib/docker/tmp/...: no such file or directory'. What is the likely cause?
FROM ubuntu COPY ./config /etc/config
When building, you get an error: 'COPY failed: stat /var/lib/docker/tmp/...: no such file or directory'. What is the likely cause?
Docker
FROM ubuntu COPY ./config /etc/config
Attempts:
2 left
💡 Hint
Check if the source folder is present where Docker expects it.
✗ Incorrect
The error means Docker cannot find the source folder in the build context. The destination path inside the container is valid and permissions are not checked at build time.
✅ Best Practice
expert3:00remaining
What is the best practice for copying files to reduce Docker image size?
You want to copy only necessary files into your Docker image to keep it small. Which COPY instruction approach is best?
Attempts:
2 left
💡 Hint
Think about how to prevent unwanted files from being sent to Docker build.
✗ Incorrect
Using .dockerignore excludes files from the build context, so COPY only adds needed files, reducing image size. Copying entire folders or files one by one is less efficient. ADD has extra features but is not recommended for simple copying.