kartoza / docker-postgis

Dockerfile for postgis
GNU General Public License v2.0
660 stars 313 forks source link

Can't start container with existing volume. #440

Open webpalych opened 1 year ago

webpalych commented 1 year ago

What is the bug or the crash?

I updated my application and needed to rebuild images, so I restarted my docker-compose and postgis container no longer starts. In container logs I see an error "ERROR: must be superuser to alter superuser roles or change superuser attribute". If i don't use volume or use new empty volume, container starts.

Fragment of my docker-compose.yml

my-app.db:
    image: kartoza/postgis:14-3.3
    restart: always
    environment:
      POSTGRES_PASSWORD: $DB_PASSWORD
      POSTGRES_USER: $DB_USER
      POSTGRES_DB: $DB_NAME
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}" ]
      interval: 5s
      timeout: 5s
      retries: 5
    ports:
      - '5433:5432'
    volumes:
     - ./postgres-data:/var/lib/postgresql/14

Steps to reproduce the issue

_

Versions

kartoza/postgis:14-3.3

Additional context

No response

NyakudyaA commented 1 year ago

Can you try changing permission for your data directory before running postgres.

webpalych commented 1 year ago

Wich permission directory should have? Docker created directory postgres-data drwxr-xr-x 3 root root 4096 postgres-data postgres-data/main drwxr-x--- 19 systemd-network systemd-network 4096 main

NyakudyaA commented 1 year ago

I suggest you check out the option to run the image as none root https://github.com/kartoza/docker-postgis#rootless-mode