Challenge - 5 Problems
Docker File Copy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Copying a file from host to container
You run the command
docker cp ./app/config.yaml mycontainer:/app/config.yaml. What is the expected result?Attempts:
2 left
💡 Hint
Remember the syntax is
docker cp source_path container:destination_path to copy files into a container.✗ Incorrect
The docker cp command copies files between host and container. When the source is a host path and the destination is container:path, it copies from host to container.
💻 Command Output
intermediate2:00remaining
Copying a directory from container to host
What happens when you run
docker cp mycontainer:/var/logs ./logs_backup?Attempts:
2 left
💡 Hint
Check if the source is container:path and destination is host path.
✗ Incorrect
When copying from container to host, docker cp copies the directory or file preserving structure at the destination path.
❓ Troubleshoot
advanced2:00remaining
Why does this docker cp command fail?
You run
docker cp /home/user/data.txt mycontainer:/data/ but get an error: Error: No such container:path: mycontainer:/data/. What is the most likely cause?Attempts:
2 left
💡 Hint
Check if the container name is correct and the container is running.
✗ Incorrect
The error indicates docker cannot find the container or the path inside it. Usually the container name is wrong or container is stopped.
✅ Best Practice
advanced2:00remaining
Best practice for copying large files into containers
Which approach is best when you need to copy a large file repeatedly into a container during development?
Attempts:
2 left
💡 Hint
Think about avoiding repeated copying and making changes instantly visible.
✗ Incorrect
Mounting a host directory as a volume allows instant file changes without copying repeatedly.
🔀 Workflow
expert3:00remaining
Order the steps to copy a file from host to a running container and verify it
Arrange these steps in the correct order to copy a file named
settings.json from the host to a running container named webapp and verify the copy.Attempts:
2 left
💡 Hint
You must confirm the container is running before copying files.
✗ Incorrect
First check container is running, then copy file, then open shell, then verify file inside container.