Complete the command to start a container that prints a message.
docker run --rm alpine echo [1]The command docker run --rm alpine echo Hello, World! runs a container that prints the message. Quotes are not needed here.
Complete the command to create a file inside a container.
docker run --rm alpine sh -c "echo 'data' > [1]"
The /tmp directory is commonly used for temporary files inside containers. This file will be created there.
Fix the error in the command to keep a file after the container stops.
docker run --rm -v [1]:/data alpine sh -c "echo 'save me' > /data/file.txt"
Mounting a host directory (like /host/path) to /data inside the container saves files outside the ephemeral container filesystem.
Fill both blanks to create a volume and mount it to persist data.
docker volume [1] mydata && docker run -v mydata:[2] alpine sh -c "echo 'persist' > /data/file.txt"
First, create a volume with docker volume create mydata. Then mount it inside the container at /data to persist files.
Fill all three blanks to explain ephemeral filesystem behavior.
When a container stops, all files in [1] are lost unless [2] or [3] are used.
The container's writable layer is ephemeral. To keep data, use volumes or bind mounts which store data outside the container.