chown error on bind mount when trying to launch postgres via docker compose
See original GitHub issueRancher 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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:25
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Receiving an error from a docker-compose that the user must ...
Details on the issue. The behavior observed by the OP definetely comes from a UID/GID mismatch, given that the specification volumes: - ....
Read more >Troubleshoot volume errors - Docker Documentation
This topic discusses errors which may occur when you use Docker volumes or bind mounts. Error: Unable to remove filesystem. Some container-based utilities, ......
Read more >Receiving an error from a docker-compose that the user must ...
(which can be viewed as a docker-compose equivalent of docker run -v "$PWD/postgres-data:/var/lib/postgresql/data" … ) bind-mounts the $PWD/postgres-data ...
Read more >Solutions for Operation not permitted error when Postgresql is ...
When PostgreSQL is runnign on Docker and using NFS volume for its persistent storage, Operation not permitted error occurs when PostgreSQL ...
Read more >Container permission denied: How to diagnose this error
Why does your container fail with "permission denied"? ... Many users' only choice is to run with --privileged mode. When the container runs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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. 😄