-1

I have set up Docker in a multi-user environment with the following daemon settings

{
  "userns-remap": "default",
  "data-root": "/data/docker"
}

where /dev/sda1/ is mapped to /data as follows:

/dev/sda1 /data ext4 rw,relatime,quota,usrquota,grpquota,prjquota 0 0

I added the quota options to enable setting up constraints on Docker volumes, and defined a new volume with the following command:

docker volume create --driver local --opt type=volume --opt device=/dev/sda1 --opt size=750G vitis

docker volume inspect vitis prints the following information:

[
    {
        "CreatedAt": "2023-03-25T23:01:23-07:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/data/docker/1214112.1214112/volumes/vitis/_data",
        "Name": "vitis",
        "Options": {
            "device": "/dev/sda1",
            "size": "750G",
            "type": "volume"
        },
        "Scope": "local"
    }
]

When I try to run a new container with the following command, I get an error related to mounting the volume.

docker run -p 6080:80 -p 5900:5900 -e RESOLUTION=2560x1440 --name $(whoami) -v /dev/shm:/dev/shm -v vitis:/vitis_projects vitis
docker: Error response from daemon: error while mounting volume '/data/docker/1214112.1214112/volumes/vitis/_data': failed to mount local volume: mount /dev/sda1:/data/docker/1214112.1214112/volumes/vitis/_data: no such device.
ERRO[0000] error waiting for container: context canceled

Can you please help me identify the source of the issue and resolve it?

Matt
  • 111
  • 4
  • I have no experience with using devices directly as docker volumes, but I can't imagine that it works to define a device in docker AND mount it as a regular file system at the same time. – Gerald Schneider Mar 26 '23 at 06:55

1 Answers1

2

This should normally result in mounting /dev/sda1 on both /data and /data/docker/.../_data if it ever worked.

That's clearly not what you want when a simple docker volume create vitis would have sufficed once the daemon was properly configured and the device mounted on /data.

Edit: adding --opt size=750G will create a volume but it won't actually do anything (size is a generic option that's only recognized for tmpfs AFAIK). If you want to setup quotas, you need to setup quotas separately.

Ginnungagap
  • 2,595
  • 10
  • 13
  • You are absolutely right. `docker volume create --opt size=750G vitis` works flawlessly. – Matt Mar 26 '23 at 16:12
  • Thanks for your answer and clarification about the size option. Are you referring to the Linux `quota` package or something else? – Matt Mar 29 '23 at 15:28
  • 1
    Yes, the quota package would allow you to setup per directory quotas (through projects). – Ginnungagap Mar 29 '23 at 17:59