79210505

Date: 2024-11-21 09:31:40
Score: 1
Natty:
Report link

Well, one sleepless night and I found the answer. Let's inspect my docker compose file I use to deploy my app with db:

networks:
  app-network:
    driver: bridge

services:
  app-db:
    container_name: 'app-db'
    image: postgres:16
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
      POSTGRES_HOST_AUTH_METHOD: md5
    ports:
      - "5432:5432"
    networks:
      - app-network
    volumes:
      - postgres-data:/var/lib/postgresql/data

  app:
    ...

I've renamed postgres user in db to super but I did not renamed it in docker compose file. I thought if I have a db container volume, all data will be stored in it, including users and roles. And it was but... It seems that superuser has its own rules. So now my postgres db knows about super user. It knows that it is SUPERUSER, but it is not, because on fresh deploy with docker-compose up DB was created not by super, but by postgres user (from docker compose file). When I changed pg user credentials to super in docker compose file, it works fine. Also, I don't want to store my credentials in docker compose file, because I want to store this file in git repository. So I change db credentials in this file before any deploy from now on. Thanks everyone and good luck!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Alexander Plekhanov