Docker Community Forums

Share and learn in the Docker community.

Create docker volume with options


(Qiulei1guo) #1

There is is very limited information regarding create volume with options " ".

I just want to create a volume with limited size, I tried,

docker volume create --opt o=size=10m hello-volume

, when run a simple hello world container with “docker run -v hello-volume:/hello -it ubuntu /bin/bash”, I got the error as something like “docker: Error response from daemon: …no such device”…

So I assumed we must give the full options when creating the volume, such as

“docker volume create --driver local --opt type=*** --opt device=*** --opt o=size=10m hello-volume”

If so, what are the “type” and “device” here? I guess the device actually is a path to any directory? I tried

“docker volume create --driver local --opt type=volume --opt device=/ --opt o=size=10m hello-volume”.

When tried to run the container as “docker run -v hello-volume:/hello -it ubuntu /bin/bash” I got the error as “docker: Error response from daemon: error while mounting volume ‘/var/lib/docker/volumes/hello-volume/_data’: error while mounting volume with options: type=‘volume’ device=’/’ o=‘size=10m’: no such device.”.

I tried

docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=10m hello-volume

which finally works, but the data is in memory which is not persistent. So can any one point out what are the options for “type” and “device” when creating the volume (or what’s the default one if we don’t give any options)?