I am reading about volumes in docker, and am a bit confused.
One way we work with them is by creating a volume and then running a container using it:
docker volume create data_volume
docker run -v data-volume:/var/opt/project bash:latest \
bash -c "echo Testing-Volume> /var/opt/project/testing.txt"
First, we create a docker volume data-volume on host, and then map it to /var/opt/project in container. So when a file is created/modified in /var/opt/project, all those changes would be persisted to data-volume in host OS. Persistence is achieved.
But I also see volume created in dockerfile:
FROM ubuntu:latest
# Create a volume for storing application logs
VOLUME /var/log/app
.....
How does this one work, as there is no mapping to some persistent storage on host OS?