Mount external drive to a volume and attach it to a container

I have an external drive mounted on the following path
/media/pi/mydrive
I am trying to make this external drive as my named volume container to store the data. The application stores as all the data in /var/www/html/

I am guessing I have to create a volume container for the external drive and attach the same when I running the application container. I normally follow the below format . I am lost on how to make this happen in this case. Any help is appreciated.

docker create -v <volume.name>:path --name <container.volume.name> arm32v6/alpine:latest

docker run -d -v <volume.name>:path --name <container.name> --volumes-from <container.volume.name> arm32v7/nextcloud

you don’t need volumes-from unless it is ANOTHER volume in addition to the named volume
the volume create has nothing to do with a container

docker volume create --name fred /media/pi/mydrive    <--- only do once
docker run -v fred:/var/www/html/

I did try the docker volume create command but am getting the following error

Conflicting options: either specify --name or provide positional arg, not both

sorry, I got the syntax wrong…

you will need to use the --opt parm to specify the source path

see the doc

Thanks very much. It works now :slight_smile:

@ezspam I am facing the same problem as that of yours. Can you give the exact command you used to mount a external drive to a volume

I use the following command to create a volume

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

Note: /dev/mmcblk0p2 is ext4 partition.

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’.

@sdetweil @ezspam Any help will be greatly helpful. Thanks.