Docker-compose volume mount with fixed device ID

I am using docker compose (context: home server, OS is Manjaro Gnome) and use a service called FileRun as my filecloud. Filerun can be compared to Nextcloud. It supports webDAV.
The issue is that webDAV believes all my files have changed, when I reboot my server. This is caused by Docker giving a new device ID to a volume mount after restarting or rebooting.

This is confirmed by running stat command within the container on the mounted volume:
before a reboot:

 root@d0ec110775a0:/# stat /user-files
  File: /user-files
  Size: 120             Blocks: 0          IO Block: 4096   directory
Device: 2ah/42d Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ asterix)   Gid: ( 1000/ asterix)
Access: 2022-10-12 09:48:42.281721759 +0000
Modify: 2022-10-12 09:48:42.281721759 +0000
Change: 2022-10-12 09:48:42.281721759 +0000
 Birth: -

After a reboot:

root@d0ec110775a0:/# stat /user-files
  File: /user-files
  Size: 120             Blocks: 0          IO Block: 4096   directory
Device: 10002fh/1048623d        Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ asterix)   Gid: ( 1000/ asterix)
Access: 2022-10-12 09:48:42.281721759 +0000
Modify: 2022-10-12 09:48:42.281721759 +0000
Change: 2022-10-12 09:48:42.281721759 +0000
 Birth: -

Notice the value for Device has changed.

To solve this, I want to mount this volume with a fixed ID. This can be done via docker according to the manual: docker volume create | Docker Documentation
Example:

docker volume create --driver local \
     --opt type=tmpfs \
     --opt device=tmpfs \
     --opt o=size=100m,uid=1000 \
     --opt ID=2ah/42d \
     foo

But how could I possibly do this via docker-compose syntax?
And I don’t want to set type, device, size etc just ID.

Currently, mounting just happens within the container section of my compose:

    volumes:
      - $DATAPOOL/users:/user-files

I already figured out the syntax, but whatever ID I fill in (made up), I always get the exact same error with a totally different ID:

docker-compose up -d                                                                                                                                                         
[+] Running 0/1
 ⠴ Container filerun  Creating                                                                                                                                                                
Error response from daemon: failed to mount local volume: mount /mnt/pool/users:/user-files:/var/lib/docker/volumes/docker_userdata/_data, data: id=2aho42d: no such device

My compose, in the container section I use this:

    volumes:
      - userdata:/user-files

And at the bottom:

volumes:
  userdata:
    driver: local
    driver_opts:
      type: bind
      device: $DATAPOOL/users
      o: id=abcdef

$DATAPOOL = /mnt/pool.

Why do I get the error, and what does it mean, the ID in the error is a different one.

I tried it and it gave me the same ID when I mounted something from the host. I don’t know why it would do otherwise unless you are mounting a tmpfs volume which you quoted. Which I didn’t try but it would be understandable, because that is not a persistent volume. I didn’t try network filesystem either. Is your mounted folder is on a network filesystem?

I also tried the command that you shared to create a tmpfs volume with custom ID, and it failed because ID is not a valid option. Where did you see that used?

I have noticed that this topic was created in the “Community” category which is not for asking from the communuty but asking about the community, events, etc…:

So I moved it to Open Source Projects » Compose.