Pages

Saturday, August 5, 2023

Docker volume ?

Docker volume ?


Volumes are stored in a part of the host file system which is managed by docker (/var/lib/docker/volumes/ on Linux). Non-Docker processes should not modify this part of the file system. Volumes are the best way to persist data in docker.

Sharing with one or more containers are allowed.

Note: To attach multiple volumes to container use -v/--mount flag more than once.


Commands:

docker run -d \
--name devtest1 \
--mount source=myvol1,target=/qpath \
nginx:latest

$ docker run -d --name devtest1 --mount source=myvol1,target=/qpath nginx:latest
$ docker volume inspect myvol1

docker run -d \
--name devtest2 \
-v myvol2:/app \
nginx:latest

$ docker run -d --name devtest2 -v myvol2:/app nginx:latest
$ docker volume inspect myvol2

No comments:

Post a Comment