1

I always get role x does not exist which means the db was created with the default username and my env vars was ignored, any idea whats going on here?

Docker-compose.yml

version: '3.1'

services:
  PostgreSQL:
    container_name: db-name
    image: postgres:12
    restart: always
    environment:
      POSTGRES_PASSWORD: ${PG_PASSWORD}
      POSTGRES_USER: ${PG_USERNAME}
      POSTGRES_DB: ${PG_DB_NAME}
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    ports:
      - 5432:5432

When I look in kitematic I see the correct env variables and values, but nothing is taking in consideration by the db

3
  • Are you sure the database was not already created? It will only be created and initialized if the files in /var/lib/postgresql/data from your mounted volume are empty. Commented Feb 8, 2020 at 13:27
  • I up with forece recreate docker-compose up --force-recreate I don't think the db will persist Commented Feb 8, 2020 at 13:53
  • I tried docker-compose down --remove-orphans --volumes still same problem Commented Feb 8, 2020 at 13:55

1 Answer 1

3

Try doing docker-compose down to remove the container and do again docker-compose up, you can get more help from this link

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

1 Comment

thank you for the link I found an answer there, I had the manually delete the ./postgres-data created by docker compose

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.