After you have finished using your Docker persistent storage volumes you can remove them from the environment so you can clean them up and don’t consume more storage that what is really needed. Here is what you have to do do clean those up.
List your volumes
docker volume ls
You will see your docker volumes stored in your /vsanDatastore/dockvols folder
Remove the volumes not needed
docker volume rm volumename
ex: docker volume rm MyVolume
This will remove the volume from the docker host and will also remove it from the VMware vSphere datastore.
You can check the volume with docker volume ls or docker volume inspect commands.
Create a container with persistent storage
docker run –rm -it -v Volumename:/mnt/mymount containerimage.
docker run –rm -it -v BusyBox1:/mnt/myvol busybox
Create a file in the persistent storage
In your container go to the directory you specified in the previous command. In our case it is /mnt/myvol
Create a quick file ex: touch file1 and then add some information to it.
We have created a file in the persistent storage not in the container file system.
Now you can exit your container. ex: exit
Create a different container and attach the persistent volume
I will download a new image for an Ubuntu:latest container and mount the persistent storage volume.
docker run –rm -it -v BusyBox1:/mnt/myvol ubuntu
Change to the same directory /mnt/myvol and see that you can browse the file was created before.
Why is this important?
This allows the developers or administrators to provide a persistent storage that can be used across container reboots to save data outside the container. This can be a great use case for database or shared data that can be used for different containers.
You may have heard that VMware released a docker plugin. This plugin allows the developers use persistent storage and store it in the VMware datastore while allowing IT Administrators the capability to manage their environment their way.
In this post I will go thru the steps to add the all the components to the ESXi server and to the VM’s
To download the binaries I used a Ubuntu machine.
1. create a folder to download the files. ex: mkdir vmware