Home > database >  What is the meaning of the type/o/device flags in driver_opts in the docker-compose file?
What is the meaning of the type/o/device flags in driver_opts in the docker-compose file?

Time:10-16

I am working on a project where I have to create costum docker containers with costum volumes etc. As I have to use some driver_opts, I am wondering, what the flags

type: XXX
o: XXX
device: XXX

in a docker-compose file actually mean. I see all the people using them, but the docker manuals and all the resources I found so far couldn't provide satisfying answers. I cannot even find a simple list of what arguments you could pass to all theses flags.

thanks in advance!

CodePudding user response:

From man mount:

mount [-fnrsvw] [-t fstype] [-o options] device mountpoint

To summarize:

type: AAA
o: BBB
device: CCC

is (more or less*) equivalent to: mount -t AAA -o BBB CCC <docker_generated_mountpoint>

* - there is some parsing https://github.com/moby/moby/blob/8d193d81af9cbbe800475d4bb8c529d67a6d8f14/volume/local/local_unix.go#L122

I cannot even find a simple list of what arguments you could pass to all theses flags.

This depends on the particular driver you are using. man mount.cifs differs from man mount.nfs, etc.

CodePudding user response:

From docker-compose driver_opts:

driver_opts specifies a list of options as key-value pairs to pass to the driver for this volume. Those options are driver-dependent.

volumes:
  example:
    driver_opts:
      type: "nfs"
      o: "addr=10.40.0.199,nolock,soft,rw"
      device: ":/docker/example"

In fact, these opts should exactly same with the one when you use docker run, see Driver-specific options:

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

You should in that official document find other opts for other kinds of driver like tmpfs, btrfs etc.

tmpfs:

$  docker volume create --driver local \
    --opt type=tmpfs \
    --opt device=tmpfs \
    --opt o=size=100m,uid=1000 \
    foo

btrfs:

 docker volume create --driver local \
    --opt type=btrfs \
    --opt device=/dev/sda2 \
    foo

So, these options is really different depends on the driver type you choose.

  • Related