You ran the command docker volume ls after creating a volume named mydata. What will the output show?
docker volume ls
Remember that docker volume ls shows the driver and volume name columns.
The docker volume ls command lists volumes with two columns: DRIVER and VOLUME NAME. Since you created mydata, it appears under VOLUME NAME with the driver local.
Which reason best explains why Docker volumes are used for persistent data?
Think about what happens to data inside a container when the container is removed.
Docker volumes store data outside the container's writable layer, so data remains safe even if the container is deleted or recreated.
Given this snippet in docker-compose.yml, which option correctly mounts the host directory /home/user/data to the container path /app/data?
services:
app:
image: myapp
volumes:Remember the format is host_path:container_path.
In Docker Compose, to mount a host directory, you specify the host path first, then the container path separated by a colon.
You created a container with a volume, but after restarting the container, the data inside /data is missing. What is the most likely cause?
Check the volume mount path in the container.
If the volume is not mounted to the correct container path, data written inside the container will not be saved to the volume and will be lost on restart.
Put these steps in the correct order to create a Docker volume and use it in a container.
Think about creating the volume before using it in a container.
First, create the volume. Then run the container with the volume mounted. Next, write data inside the container to the volume path. Finally, stop and remove the container but keep the volume for data persistence.