0
votes

This Works

To create the docker volume without specifying the disk size:

  docker volume create disk1

To mount the volume(disk1) to a container

  docker run -itd -v disk1:/data ubuntu

This is Not Working

Now creating the docker volume by specifying a size of 100mb

  docker volume create --name disk2 --opt o=size=100m

To mount the volume(disk2 which is of size 100 MB) to a container

  docker run -itd -v disk2:/data ubuntu

when I run these commands I was getting the following error

docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/disk2/_data': missing device in volume options.

1
What OS are you using? - Sathyajith Bhat
NAME="Ubuntu" VERSION="18.04 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu Bionic Beaver (development branch)" VERSION_ID="18.04" HOME_URL="ubuntu.com" SUPPORT_URL="help.ubuntu.com" BUG_REPORT_URL="bugs.launchpad.net/ubuntu" PRIVACY_POLICY_URL="ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic - electrodragon
I am using ubuntu 18.04 - electrodragon

1 Answers

5
votes

This error occurs because set of driver options are missing

"--opt type=" and "--opt device=" is mandatory when you are providing with size of the docker volume "--opt o=size="

So create volume with all the mandatory options and link with the container.

try

 docker volume create --name disk2 --opt type=tmpfs --opt device=tmpfs --opt o=size=100m

then

 docker run -itd -v disk2:/data ubuntu

It works.