Docker Volume
It is possible to store data within the writable layer of a container, but there are some downsides:
The data won't persist when that container is no lunger running.
A container's writable layer is tightly coupled to the host machine where the container is running.
Writing into a container's writable layers requires a storage drive to manage the filesystem.
the storage driver provides a union filesystem, using the Linuz kernel.
-Stop the running container
# docker stop nginx
nginx is the container name that had assigned before.
-Run new container with volume
# docker run -d --name nginx-persistent -v nginx-volume:/usr/share/nginx/html/ -p 8080:80 custom-nginx
-Create & Modify some file on the mounter volume
# echo "this is created in a persistent volume" > /var/lib/docker/volumes/nginx-volume/_date/index.html
-remove & recreate the container to verify the mounted data is persistent
The data won't persist when that container is no lunger running.
A container's writable layer is tightly coupled to the host machine where the container is running.
Writing into a container's writable layers requires a storage drive to manage the filesystem.
the storage driver provides a union filesystem, using the Linuz kernel.
-Stop the running container
# docker stop nginx
nginx is the container name that had assigned before.
-Run new container with volume
# docker run -d --name nginx-persistent -v nginx-volume:/usr/share/nginx/html/ -p 8080:80 custom-nginx
-Create & Modify some file on the mounter volume
# echo "this is created in a persistent volume" > /var/lib/docker/volumes/nginx-volume/_date/index.html
-remove & recreate the container to verify the mounted data is persistent