-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?

1
  • 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. Mar 26 at 6:55

1 Answer 1

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.

3
  • You are absolutely right. docker volume create --opt size=750G vitis works flawlessly.
    – Matt
    Mar 26 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 at 15:28
  • 1
    Yes, the quota package would allow you to setup per directory quotas (through projects). Mar 29 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.