Score:-1

Mounting a docker volume fails with the `no such device` error

tm flag

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?

in flag
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.
Score:2
gu flag

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.

Matt avatar
tm flag
You are absolutely right. `docker volume create --opt size=750G vitis` works flawlessly.
Matt avatar
tm flag
Thanks for your answer and clarification about the size option. Are you referring to the Linux `quota` package or something else?
Ginnungagap avatar
gu flag
Yes, the quota package would allow you to setup per directory quotas (through projects).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.