Closed timwr closed 1 year ago
Hi,
Could you share the docker-compose file you are using?
$ cat docker-compose.yml
version: "3.7"
services:
# https://hub.docker.com/r/bitnami/postgresql
# https://github.com/bitnami/bitnami-docker-postgresql/blob/master/README.md
helpme-postgresql:
image: "bitnami/postgresql:13-debian-10"
container_name: helpme-postgresl
restart: always
user: root
environment:
POSTGRESQL_REPLICATION_MODE: master
POSTGRESQL_REPLICATION_USER: user
POSTGRESQL_REPLICATION_PASSWORD: password
POSTGRESQL_USERNAME: username
POSTGRESQL_PASSWORD: password
POSTGRESQL_DATABASE: database
ALLOW_EMPTY_PASSWORD: "no"
entrypoint: 'bash -c "
echo \"ALTER ROLE username SUPERUSER;\" > /docker-entrypoint-initdb.d/superuser.sql;
/opt/bitnami/scripts/postgresql/entrypoint.sh /opt/bitnami/scripts/postgresql/run.sh
"'
ports:
- "0.0.0.0:5432:5432"
networks:
- backend
volumes:
- ./data/postgresql:/bitnami/postgresql
healthcheck:
test:
- CMD
- pg_isready
- --dbname=database
- --quiet
- --username=username
interval: 15s
timeout: 5s
retries: 6
networks:
backend:
name: backend
$ docker-compose up --build
[+] Running 1/1
✔ Container helpme-postgresl Created 0.1s
Attaching to helpme-postgresl
Error response from daemon: error while creating mount source path '/Users/user/dev/docker-postgres/data/postgresql': chown /Users/user/dev/docker-postgres/data/postgresql: permission denied
users-MacBook-Air:docker-postgres user$ chmod -R 777 data/
users-MacBook-Air:docker-postgres user$ docker-compose up --build
Attaching to helpme-postgresl
helpme-postgresl | postgresql 07:12:29.30
helpme-postgresl | postgresql 07:12:29.31 Welcome to the Bitnami postgresql container
helpme-postgresl | postgresql 07:12:29.32 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
helpme-postgresl | postgresql 07:12:29.33 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
helpme-postgresl | postgresql 07:12:29.34
helpme-postgresl | postgresql 07:12:29.36 INFO ==> ** Starting PostgreSQL setup **
helpme-postgresl | postgresql 07:12:29.52 INFO ==> Validating settings in POSTGRESQL_* env vars..
helpme-postgresl | postgresql 07:12:29.72 INFO ==> Loading custom pre-init scripts...
helpme-postgresl | postgresql 07:12:29.74 INFO ==> Initializing PostgreSQL database...
helpme-postgresl | chown: changing ownership of '/bitnami/postgresql/data': Permission denied
helpme-postgresl exited with code 0
I tried removing user: root
but then I get permission denied elsewhere :(
Everything works perfectly on docker on Linux...
Apologies @carrodher Exactly which commands do I run to ensure the directory has the correct permissions?
sudo chmod -R 777 data
sudo chown -R 1001 data
sudo chgrp -R root data
chgrp: root: illegal group name
sudo chgrp -R wheel data
Despite this, nothing seems to work. Is there anything I can do to make this container work on the Mac M1 docker? Many thanks!
What is the output of ls -la data
?
$ ls -la data
total 0
drwxrwxrwx 3 root wheel 96 Aug 4 15:16 .
drwxr-xr-x 5 user staff 160 Aug 4 15:18 ..
drwxrwxrwx 3 root wheel 96 Aug 4 15:16 postgresql
$ ls -la data/postgresql/
total 0
drwxrwxrwx 3 root wheel 96 Aug 4 15:16 .
drwxrwxrwx 3 root wheel 96 Aug 4 15:16 ..
drwxrwxrwx 2 root wheel 64 Aug 4 15:16 data
$ ls -la data/postgresql/data/
total 0
drwxrwxrwx 2 root wheel 64 Aug 4 15:16 .
drwxrwxrwx 3 root wheel 96 Aug 4 15:16 ..
It seems like whatever owner/group/permissions I give, it always fails...
$ ls -la data/
total 0
drwxrwxrwx 3 1001 wheel 96 Aug 4 15:16 .
drwxr-xr-x 5 user staff 160 Aug 4 15:18 ..
drwxrwxrwx 3 1001 wheel 96 Aug 4 15:16 postgresql
$ ls -la data/postgresql/
total 0
drwxrwxrwx 3 1001 wheel 96 Aug 4 15:16 .
drwxrwxrwx 3 1001 wheel 96 Aug 4 15:16 ..
drwxrwxrwx 2 1001 wheel 64 Aug 4 15:16 data
$ ls -la data/postgresql/data/
total 0
drwxrwxrwx 2 1001 wheel 64 Aug 4 15:16 .
drwxrwxrwx 3 1001 wheel 96 Aug 4 15:16 ..
I think it's something wrong with how Docker on the M1 handles volumes...
The group should be root
, according to the above outputs it is always wheel
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.
@timwr Hello, have you solved your issue? I have same one on my M1 13.6.
@carrodher Hello, I tried to change folder owner as: sudo chown -R 1001:1001 docker-postgresql sudo chown -R 1001:root docker-postgresql
I cannot set root group because get error: chown: root: illegal group name
And docker container start always fail with reason: mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied
My service config:
version: "3"
services:
database:
image: bitnami/postgresql:16.0.0-debian-11-r10
restart: always
environment:
- POSTGRESQL_USERNAME=user
- POSTGRESQL_PASSWORD=password
- POSTGRESQL_DATABASE=db
volumes:
- ./docker-postgresql:/bitnami/postgresql
ports:
- 5432:5432
For future readers. Solved by run:
sudo chown -R $USER:1001 docker-postgresql
Owner must be system user and group 1001
For future readers. Solved by run:
sudo chown -R $USER:1001 docker-postgresql
Owner must be system user and group 1001
@mike667 I used your solution but when I use with 16.2.0-debian-12-r5
it just show log then unexpected exit with no further reason, even I don't see any error log there. Still don't know why :(
Name and Version
bitnami/postgresql-13-debian-10
What architecture are you using?
arm64
What steps will reproduce the bug?
What is the expected behavior?
No response
What do you see instead?
Additional information
Any ideas? I have tried many things...