3

I decided to just update the postgres version via docker compose pull. And now I have an error due to a lack of rights. What's wrong? My docker-compose.yaml

services:
  postgres:
    env_file: .env
    image: 'postgres:latest'
    container_name: general_postgres
    environment:
      POSTGRES_USER: postgres_user
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: postgres_db
      PGDATA: /var/lib/postgresql/data/pgdata
    ports:
      - '5050:5432'
    volumes:
      - './pgdata:/var/lib/postgresql/data/pgdata'
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 1024M
        reservations:
          cpus: '0.25'
          memory: 256M
    command: |
      postgres -c max_connections=1000
               -c shared_buffers=256MB
               -c effective_cache_size=768MB
               -c maintenance_work_mem=64MB
               -c checkpoint_completion_target=0.7
               -c wal_buffers=16MB
               -c default_statistics_target=100
               -c password_encryption=scram-sha-256
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U postgres_user -d postgres_db
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped
    tty: true
    stdin_open: true

docker compose logs

general_postgres  | mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied
general_postgres exited with code 1 (restarting)
general_postgres  | mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied
general_postgres exited with code 1 (restarting)
general_postgres  | mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied
general_postgres exited with code 1 (restarting)
general_postgres  | mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied

I tried doing chown -Rv root:root pgdata, but it didn't help. I have no idea what happened. There may have been BREAKING CHANGES in postgres. idk

UPDATE: I found a version of the past postgres in ENV using docker image ls and docker image history --no-trunk. It was 17.6-1.pgdg13+1

1 Answer 1

1

As a result, I tried to set the version tag to 17.6 instead of latest in docker-compose.yaml. Everything is working now. I can make a small conclusion that switching to a new version completely breaks the configuration and it needs to be completely rewritten.

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.