I have some new clue. This is similar to another issue in another topic so I was confused and started to answer there referring partailly this issue.
I tried to mount /usr/local/var
into the container again but I noticed the folder inside the container was empty. When I saved something into that folder it did not appear on the host. I stopped and deleted the container, deleted each volume and tried again, and the saved file was still there inside the container. After that I mounted the root file system and realised the saved file is on the virtual machine’s filesystem. So I did not have any error message because it could create a folder inside the VM.
When I mounted /opt/homebrew/data/postgres
I got an error message. I am not sure what is the difference since none of these folders are enabled to mount in Docker Desktop settings.
However, I could finally allow to mount /opt/homebrew. I had to press Command + SHIFT + .
in the file browser window after I selected “Maintosh HD” from the drop down list. The same solution worked for /usr/local/var
but only if I had access to it without being an administrator.
It seems it was a good question after all which inspired me to test it.