I am trying to create a docker volume of a specific size in a specific place. I have been looking at this for some time and can not find the answer.
I do not want the volume to be created in /var/lib/docker/volumes, but in /data/volumes/ where /data is a remote iscsi drive.
I have been able to create the volume in a specific place and access the volume from within the container using:
sudo docker run --detach --name testcontainer -v /data/volumes/testvol:/file-uploads imageName
This works fine. The directory “testvol” is created within /data/volumes/ and I can access “/data/volumes/testvol” from within my container via /file-uploads. However, the new volume is not listed on a “docker volume ls” and I don’t seem to be able to specify a volume size. I think I need something along the lines of the below but I can’t get the syntax:
sudo docker run --detach --name testcontainer -v /data/volumes/testvol:/file-uploads:size=10m imageName
Alternatively I can use volume create:
sudo docker volume create --opt o=source=/data/volumes --opt o=size=100m --opt device=/data/volumes --opt type=volume testvol
This returns no errors, but it always creates the volume in /var/lib/docker/volumes and not in /data/volumes. I am not sure I understand the device switch properly.
I dont really want to be using symbolic links in the /var/lib/docker/volumes directory over to /data/volumes.