[bitnami/postgresql] "Permission denied" that occurs even when UID is 1001
Name and Version
bitnami/postgresql:11
What steps will reproduce the bug?
- Write docker-compose.yml
version: '3.8'
networks:
postgres:
driver: bridge
services:
postgres__main:
image: bitnami/postgresql:11
restart: always
networks:
- postgres
ports:
- "5432:5432"
volumes:
- "./data/main/data:/bitnami/postgresql/data"
environment:
POSTGRESQL_PASSWORD: postgres
POSTGRESQL_REPLICATION_MODE: master
POSTGRESQL_REPLICATION_USER: postgres
POSTGRESQL_REPLICATION_PASSWORD: postgres
- Run command
docker-compose up
What is the expected behavior?
Postgres Container running
What do you see instead?
postgres__main_1 | postgresql 07:24:08.12
postgres__main_1 | postgresql 07:24:08.12 Welcome to the Bitnami postgresql container
postgres__main_1 | postgresql 07:24:08.13 Subscribe to project updates by watching https://github.com/bitnami/containers
postgres__main_1 | postgresql 07:24:08.13 Submit issues and feature requests at https://github.com/bitnami/containers/issues
postgres__main_1 | postgresql 07:24:08.13
postgres__main_1 | postgresql 07:24:08.16 INFO ==> ** Starting PostgreSQL setup **
postgres__main_1 | postgresql 07:24:08.19 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgres__main_1 | postgresql 07:24:08.20 INFO ==> Loading custom pre-init scripts...
postgres__main_1 | postgresql 07:24:08.20 INFO ==> Initializing PostgreSQL database...
postgres__main_1 | mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied
Additional information
my directory permission
$ ls -al ./data/main
drwxrwx--- 3 1001 1001 4096 8월 2 16:19 .
drwxrwx--- 3 1001 1001 4096 8월 2 16:02 ..
drwxrwx--- 2 1001 1001 4096 8월 2 16:19 data
Hi,
Bind-mounting volumes is always problematic in non-root containers. Could you try adding more open permissions to the folder like 777?
Hello @javsalgar ,
I changed the permission to 777 but I get the error Operation not permitted.
postgres__main_1 | postgresql 16:12:34.70 INFO ==> ** Starting PostgreSQL setup **
postgres__main_1 | postgresql 16:12:34.72 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgres__main_1 | postgresql 16:12:34.72 INFO ==> Loading custom pre-init scripts...
postgres__main_1 | postgresql 16:12:34.73 INFO ==> Initializing PostgreSQL database...
postgres__main_1 | chmod: changing permissions of '/bitnami/postgresql/data': Operation not permitted
postgres__main_1 | postgresql 16:12:34.74 WARN ==> Lack of permissions on data directory!
Could you add more details on the platform you are using to run docker?
- OS: Ubuntu 22.04 LTS (GNU/Linux 5.15.0-43-generic x86_64)
- Docker engine version: 20.10.17, build 100c701
- Docker compomse version: v2.6.1
Would this be enough? Let me know if you need anything more.
Hello @javsalgar ,
I'm getting (probably) the same error on windows.
docker-compose.yml
version: "3.8"
volumes:
app_pgdata:
services:
postgresql:
image: bitnami/postgresql:14
ports:
- "5432:5432"
volumes:
- "app_pgdata:/bitnami/postgresql"
Log
Starting docker_postgresql_1 ... done
Attaching to docker_postgresql_1
postgresql_1 | postgresql 12:51:02.61
postgresql_1 | postgresql 12:51:02.61 Welcome to the Bitnami postgresql container
postgresql_1 | postgresql 12:51:02.61 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
postgresql_1 | postgresql 12:51:02.61 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
postgresql_1 | postgresql 12:51:02.61
postgresql_1 | postgresql 12:51:02.63 INFO ==> ** Starting PostgreSQL setup **
postgresql_1 | postgresql 12:51:02.66 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgresql_1 | postgresql 12:51:02.67 INFO ==> Loading custom pre-init scripts...
postgresql_1 | postgresql 12:51:02.67 INFO ==> Initializing PostgreSQL database...
postgresql_1 | chmod: changing permissions of '/bitnami/postgresql/data': Operation not permitted
postgresql_1 | postgresql 12:51:02.69 WARN ==> Lack of permissions on data directory!
postgresql_1 | chmod: changing permissions of '/bitnami/postgresql/data': Operation not permitted
postgresql_1 | postgresql 12:51:02.69 WARN ==> Lack of permissions on data directory!
postgresql_1 | postgresql 12:51:02.69 INFO ==> pg_hba.conf file not detected. Generating it...
postgresql_1 | postgresql 12:51:02.69 INFO ==> Generating local authentication configuration
- OS: Microsoft Windows 11 Pro (21H2, Build 22000.856)
- Docker: v20.10.17 (build 100c701)
- Docker compose: v1.29.2 (build 5becea4c)
Similar Issue - i changed permission and rm and made new directory as well
redis 03:18:46.30 INFO ==> Initializing Redis
mkdir: cannot create directory '/bitnami/redis': Permission denied
redis 03:19:12.52 INFO ==> Initializing Redis
redis 03:19:12.50 INFO ==> ** Starting Redis setup **
redis 03:19:12.50
redis 03:19:12.50 Submit issues and feature requests at https://github.com/bitnami/containers/issues
redis 03:19:12.49 Subscribe to project updates by watching https://github.com/bitnami/containers
redis 03:19:12.49 Welcome to the Bitnami redis container
version: '3'
services:
redis:
container_name: redis
image: bitnami/redis:latest
expose:
- 6379
volumes:
- /opt/appdata/redis:/bitnami
environment:
REDIS_PASSWORD: "admin"
networks:
- proxy-self
restart: unless-stopped
Hello @rutvik2611.
Thank you for your comment.
Based on what your error shows us, it seems that you don' have the permissions of the corresponding directories configured. Try to configure them with the corresponding permissions. For example, using the chmod command: sudo chown -R 1001:1001 ${YOUR_PATH}.
For clarification, the command should be chown -R 1001:root ${YOUR_PATH} or chown -R 1001:1001 ${YOUR_PATH} depending on the group you choose to use.
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.