rancher-desktop: chown error on bind mount when trying to launch postgres via docker compose
Rancher Desktop Version
0.7.1
Rancher Desktop K8s Version
1.22.5
What operating system are you using?
macOS
Operating System / Build Version
macOS Monterey 12.1
What CPU architecture are you using?
arm64 (Apple Silicon)
Windows User Only
No response
Actual Behavior
When trying to launch a Postgres container with a bind mount, it doesn’t work because of a chown related error to the folder at startup
Steps to Reproduce
Clone the repo https://github.com/docker/awesome-compose, go to the folder nginx-golang-postgres, edit the file docker-compose.yml to use a bind mount like the following
services:
backend:
build: backend
secrets:
- db-password
depends_on:
- db
db:
image: postgres
restart: always
secrets:
- db-password
volumes:
- $PWD/db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
expose:
- 5432
proxy:
build: proxy
ports:
- 8000:8000
depends_on:
- backend
#volumes:
# db-data:
secrets:
db-password:
file: db/password.txt
Run the following command: docker compose up
Result
Error response from daemon: error while creating mount source path '~/github.com/docker/awesome-compose/nginx-golang-postgres/db-data': chown ~/github.com/docker/awesome-compose/nginx-golang-postgres/db-data: permission denied
Expected Behavior
I would expect to be able to access locally the folder as a bind mount in order to access and modify the files directly
Additional Information
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 38
- Comments: 47 (7 by maintainers)
You can include the following content in
~/Library/Application\ Support/rancher-desktop/lima/_config/override.yaml:It should allow this to work (you must restart Rancher Desktop to apply this setting).
Caveats: any symlinks on your host system will be seen as the referenced object in the VM/container. If there’s a symlink loop, and something tries to follow it, it’ll eat its own tail (potentially slowly depending on how things behave).
The databases I’m playing w/ (postgres, redis, neo4j) don’t generally deal in symlinks, so I believe it’s a satisfactory configuration for my database use cases. (It may create a mess for all of my other use cases, but that remains to be seen.)
FYI…
Switching over to 9P does indeed solve part of the problem for me. The chown issue disappears but it was replaced with file create issues in my case, changing to loose permissions on all dirs (777) resolved that however.
Still an issue with Rancher Desktop 1.4.1, exactly as described above. This is the only thing preventing me from using Rancher as opposed to Docker.
I too am keen to see this resolved. Having been a Docker Desktop user, and developing on my M1 mac, I have no issues with permissions when starting docker containers. All my project files are owned by my id, however the docker containers that start (eg: Postgres or mysql) while they may attempt to chown and change permissions on files as part of their normal startup process - those attempts don’t fail and those containers run happily.
On rancher desktop, those file mod permissions fail with permission denied errors - and if I change the uid/gid (from the host) to what the process is running on in the container, then those files are not visible and file not found errors pursue.
I changed from Docker Desktop on my company issued device, as I didn’t want my company to think that I was using commercial software without meeting the license requirements, nor did I want Docker to think I was doing the same.
As much as I am glad that Rancher Desktop exists,
I cannot use it as a functional replacement to Docker Desktop 😦EDIT: I just tried the 9p in the override.yml as suggested above - and it does go along way to making Rancher Desktop a functional replacement to Docker Desktop. I had an issue with permissions, which I had to fix “in container” but once done, things were working better. 😄
This ended up being a problem with colima on my m1 mac for me and ultimately with the lima vm, I had to upgrade to ventura and switch colima to
vzvmtype and set my mountype tovirtiofsthen uninstall colima and lima and reinstall them and the mount workedsteps I took
colima templateand set vmType and mountTypebrew uninstall colima && brew uninstall limaThis solved my issue, thanks for posting
I think this may be an issue with the underlying
lima. I experience the exact same behavior using either Rancher Desktop or colima.Possibly related lima-vm/lima#504
I was able to resolve the issue on mac with the following setup:
I also allow Rancher Desktop to use admin permission and disabled Traefik.
They converted that issue into a discussion https://github.com/lima-vm/lima/discussions/505 marked it as answered.
To me, it doesn’t feel like the answer is addressing the broader concerns raised above.
I’m trying to use Rancher Desktop with the simplest compose file ever and get a similar error:
Running “docker compose up” gives me:
It seems like the only solution is to use the
mountType: 9psolution described by @QuentinStouffs above, but according to this link - https://github.com/lima-vm/lima/issues/20#issue-895105285 (and our own devs), it’s ridicoulously slow to the point of unusable.I encountered a similar issue where on Windows hosts the non-root user inside the container no longer had write access to mounts after switching from docker-desktop to rancher-desktop.
I’m using a docker-compose file with the following volume
If the directory
${ROOT_DIRECTORY}/logsdoes not exist on the Windows Host it gets created when I run docker-compose up for the first time. The root user inside the container will be the owner of the/opt/something/logsdirectory and the non-root user inside the container will only have read access.If the directory already existed on the Windows hosts (it is not created by Rancher-Desktop), the non root user inside the container also has write access.
I guess there’s some difference in how Rancher-Desktop creates the folder on the host as compared to how Docker-Desktop did it on Windows hosts.
Thanks, I’ve already changed to Docker Desktop. Will install Rancher when this issue solved.
… and “Volumes/Mount Type” to
virtiofsat the same time. Disclaimer: I am also in testing phase for the setting 😃current workaround for me is to set VZ as emulation in preference. so far no downside for my usecase
Also having this problem but it’s across more than postgres/mongo - random containers of mine are having chown-related issues like this. I attempted the 9p workaround but that made the problem even worse (all of my containers started chaotically crashing/restarting)
It is still unreleased. Also will require macOS 13 (Ventura).