Which version of mac? And which architecture? Intel or ARM (probably does not mattter)?
How did you “looked at symlinks”? I have tried to reproduce the error without succes on MacOs Bug Sur 11.6 (ARM). I installed postgresql using Homebrew and my folder is not under /usr/local/var but /opt/homebrew/var/postgresql. I could not mount the folder because this is not enabled in Docker Desktop but my error message is different:
The path /opt/homebrew/var/var/postgres is not shared from the host and is not known to Docker.
You can configure shared paths from Docker → Preferences… → Resources → File Sharing.
See Sign in to Docker Desktop | Docker Docs for more info.
ERRO[0000] error waiting for container: context canceled
I don’t think that would solve anything but you can try if nothing else helps.
I don’t think so, but if you mounted the same folder inside a container as you used on the host that is definitely a bad idea and can cause problems so don’t do that.
I didn’t I went to the settings to browse that folder and I could not go to /opt. I had a similar issue before without Docker desktop so I created a symlink from my home folder.
I agree with @rimelek that this should not cause the error you’re seeing, but still should not be done: having two PostgreSQL services manage the same data surely doesn’t feel right, if that’s what you’re doing. But again: not the cause of the Docker error, I agree.
Any chance you’re using sudo rights to even see /usr/local/var/?
But maybe I was on the wrong track altogether … Maybe I just should have a namned volume and have the container data files with its own database persisted there. Instead of trying to use the same file as my database running in the host …
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.