Docker Community Forums

Share and learn in the Docker community.

Mont a external driver to a volume and attach it to the container

I am trying to mount a ext4 partition on /dev/mmcblk0p2 a volume and attach that to a container, but facing few issues.

I use the following command to create a volume

docker volume create --driver local
–opt type=aufs
–opt device=/dev/mmcblk0p2
ext_part

The Volume creation is successful. But when i use the volume with docker it gives the following error:

docker run -d -v ext_part:/home/root/ docker.io/vivsundar/mount_test:latest
docker: Error response from daemon: failed to mount local volume: mount /dev/mmcblk0p2:/var/lib/docker/volumes/ext_part3/_data: no such device.
See ‘docker run --help’.

Any help will be greatly appreciated. Thanks

Some volume drivers may take options to customize the volume creation. Use the -o or --opt flags to pass driver options:

$ docker volume create --driver fake
–opt tardis=blue
–opt timey=wimey
foo
These options are passed directly to the volume driver. Options for different volume drivers may do different things (or nothing at all).

The built-in local driver on Windows does not support any options.

The built-in local driver on Linux accepts options similar to the linux mount command. You can provide multiple options by passing the --opt flag multiple times. Some mount options (such as the o option) can take a comma-separated list of options. Complete list of available mount options can be found here.

For example, the following creates a tmpfs volume called foo with a size of 100 megabyte and uid of 1000.

$ docker volume create --driver local
–opt type=tmpfs
–opt device=tmpfs
–opt o=size=100m,uid=1000
foo
Another example that uses btrfs:

$ docker volume create --driver local
–opt type=btrfs
–opt device=/dev/sda2
foo
Another example that uses nfs to mount the /path/to/dir in rw mode from 192.168.1.1:

$ docker volume create --driver local
–opt type=nfs
–opt o=addr=192.168.1.1,rw
–opt device=:/path/to/dir
foo

@lewish95 Thanks for the reply. I messed up with the --opt type=aufs. That option is wrong and after changing it to --opt type=ext4 things started working properly

The correct command to create volume is

docker volume create --driver local
–opt type=aufs
–opt device=/dev/mmcblk0p2
ext_part

Thanks again !!