Data volumes in Docker containers

Data volumes in Docker containers

1)start a container with volume

here a container named test123 is created with the volume named vol123 so this is saved into path /app/ in the container the base image is Nginx

docker run -d \
--name test123 \
-v vol123:/app \

2)mounting volume to a second container

the saved data in the volume is mounted to the second container in a specified path

docker run -v vol123:/backup ubuntu

3)read only volumes

mounting volumes has a default setting as read and write but we can give only read-only permission by:ro tag

docker run -d \
--name=nginxtest \
-v nginx-vol:/usr/share/nginx/html:ro \

4)removing volumes

docker volume prune
Last updated on by vishal devxo