I am trying to create a volume on an external drive . It works with the following command
docker run -t -i -v /mnt/mydrive:/var/ ubuntu
But with the above command, I am not able to provide a name to the volume. How can I create a named volume mounted to an external drive?
Create a volume and then configure the container to use it:
$ docker volume create my_volume --driver local --opt device=/mnt/mydrive
$ docker run -t -i -v my_volume:/var/ ubuntu
Check docker docs for more options and details.
NB: Drive should be mounted first in your system. But if you want to handle that also through docker, check driver specific options where you can specify ip, write mode, file system etc.
Bind mounts (what you are doing) is not the same as named volumes.
So you cannot assign a bind mount volume a name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With