containers icon indicating copy to clipboard operation
containers copied to clipboard

[bitnami/postgresql] "Permission denied" that occurs even when UID is 1001

Open dungsil opened this issue 3 years ago • 5 comments

Name and Version

bitnami/postgresql:11

What steps will reproduce the bug?

  1. 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
  1. 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

dungsil avatar Aug 02 '22 07:08 dungsil

Hi,

Bind-mounting volumes is always problematic in non-root containers. Could you try adding more open permissions to the folder like 777?

javsalgar avatar Aug 02 '22 08:08 javsalgar

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!

dungsil avatar Aug 02 '22 11:08 dungsil

Could you add more details on the platform you are using to run docker?

javsalgar avatar Aug 03 '22 08:08 javsalgar

  • 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.

dungsil avatar Aug 03 '22 08:08 dungsil

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)

dungsil avatar Aug 12 '22 12:08 dungsil

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

rutvik2611 avatar Aug 13 '22 03:08 rutvik2611

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.

corico44 avatar Aug 19 '22 09:08 corico44

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.

github-actions[bot] avatar Sep 07 '22 01:09 github-actions[bot]

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.

github-actions[bot] avatar Sep 12 '22 01:09 github-actions[bot]