0
0
Dockerdevops~10 mins

Container filesystem is ephemeral in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to start a container that prints a message.

Docker
docker run --rm alpine echo [1]
Drag options to blanks, or click blank then click option'
AHello, World!
B"Hello, World!"
C'Hello, World!'
DHello World
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes that cause the shell to treat the message as a single argument with quotes included.
Forgetting to include the message after echo.
2fill in blank
medium

Complete the command to create a file inside a container.

Docker
docker run --rm alpine sh -c "echo 'data' > [1]"
Drag options to blanks, or click blank then click option'
A/data/file.txt
B/tmp/file.txt
C/var/file.txt
D/file.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a directory that might not exist or be writable inside the container.
Using root directory which is not recommended for temporary files.
3fill in blank
hard

Fix the error in the command to keep a file after the container stops.

Docker
docker run --rm -v [1]:/data alpine sh -c "echo 'save me' > /data/file.txt"
Drag options to blanks, or click blank then click option'
A/var/lib/docker
B/data
C/tmp
D/host/path
Attempts:
3 left
💡 Hint
Common Mistakes
Using a container path on the left side of the volume mount.
Using a system folder that is not intended for mounting.
4fill in blank
hard

Fill both blanks to create a volume and mount it to persist data.

Docker
docker volume [1] mydata && docker run -v mydata:[2] alpine sh -c "echo 'persist' > /data/file.txt"
Drag options to blanks, or click blank then click option'
Acreate
Bdata
C/data
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'remove' instead of 'create' for the volume command.
Mounting the volume to a wrong or non-existent container path.
5fill in blank
hard

Fill all three blanks to explain ephemeral filesystem behavior.

Docker
When a container stops, all files in [1] are lost unless [2] or [3] are used.
Drag options to blanks, or click blank then click option'
Athe container's writable layer
Ba volume
Ca bind mount
Dthe image
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the image with the writable layer.
Not knowing the difference between volumes and bind mounts.