Bird
0
0

What will be the output of this command?

medium📝 Command Output Q4 of 15
Docker - Production Patterns
What will be the output of this command?
docker run --rm -v myvol:/data busybox sh -c "tar cvf /backup/myvol.tar /data"
AFails because /backup directory does not exist inside the container
BCreates a tar archive of /data inside the container at /backup/myvol.tar
CCreates a tar archive on the host machine at /backup/myvol.tar
DOutputs the tar archive content to the terminal
Step-by-Step Solution
Solution:
  1. Step 1: Analyze container filesystem paths

    The busybox container does not have a /backup directory by default, so writing to /backup/myvol.tar will fail.
  2. Step 2: Understand tar file destination

    Since /backup is not mounted or created, tar cannot write the archive there, causing an error.
  3. Final Answer:

    Fails because /backup directory does not exist inside the container -> Option A
  4. Quick Check:

    Nonexistent path causes failure [OK]
Quick Trick: Ensure target directory exists or is mounted before tar output [OK]
Common Mistakes:
  • Assuming tar writes to host without volume mount
  • Expecting tar output on terminal without -v flag
  • Ignoring container filesystem isolation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes