I am creating docker volume using docker local volume driver but docker documentation has limited information about what options are available like below. How do I know what options I should use and what are the options available.
docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 foo
If you're using --driver local
(the default), they're the standard Linux mount(8) options. In most cases you don't need any at all; it is sufficient to just run
docker volume create foo
or the equivalent Docker Compose
volumes:
foo:
The only particularly notable option for routine use is that setting --opt o=bind --opt device=/some/source/dir
uses Linux mount options to create a bind mount in a Docker named volume. This is very similar to the shorter Docker -v /some/source/dir:/container/dir
bind-mount syntax.
Based on the answer by @DavidMaze and other comments on the answer.
The local
Driver has options that is platform dependent. As for the Docker Docs
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.
But if you using WSL 2
Backend for Docker in Docker for Windows there is a chance these options for linux might work.
You can view options supported by Linux mount command through here mount(8) — Linux manual page
You can pass these options to the Docker CLI using the --opt
flag as follows
docker volume create --driver local \
--opt type=tmpfs \
--opt device=tmpfs \
--opt o=size=100m,uid=1000 \
foo
This creates a tmpfs volume called foo with a size of 100 megabyte and uid of 1000
The same can be achieved in Docker Compose as follows
Docker Compose File v3
volumes:
foo:
driver: local
driver_opts:
type: "tmpfs"
o: "o=size=100m,uid=1000"
device: "tmpfs"
There are also additional Filesystem specific mount options that might be helpful for you. FILESYSTEM-SPECIFIC MOUNT OPTIONS
References:
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