Skip to main content

Posts

Showing posts with the label Docker: Working with volumes and persistent data

WORKING WITH VOLUMES AND PERSISTENT DATA IN DOCKER

We can use volumes with docker for persistent storage.To create a volume use command #docker volume create mytestvol This will create a volume named mytestvol. To list it #docker volume ls We can see our volume mytestvol is listed in it. To inspect that #docker volume inspect mytestvol The volumes that we create will be created inside /var/lib/docker/volumes.Go inside that folder and we can see that our volume mytestvol is present there To delete a volume #docker volume rm mytestvol2 Here mytestvol2 is the new volume that we created. Now we will check how to mount a volume to a container. #docker container run -dit --name mygoof --mount source=volpool,target=/vol centos:centos6 Here docker will run a new centos6 container with a new volume named volpool attached to /vol directory of centos container.Here docker will create a new volume automatically.Now check #docker volume ls We can see new volume volpool is created #docker ps We can see our container named m...