"role "postgres" does not exist" - installing Label Studio with Postgres and Docker compose -

Got it working with help from the Postgres maintainer.

Here’s what I ended up with, in case it helps someone else in future:

environment:
      - DJANGO_DB=default
      - POSTGRE_NAME=postgres
      - POSTGRE_USER=${PG_USER}
      - POSTGRE_PASSWORD=${PG_PASS}
      - POSTGRE_PORT=5432
      - POSTGRE_HOST=Postgres-LabelStudio
      - LABEL_STUDIO_HOST=${LABEL_STUDIO_HOST:-}
      - LABEL_STUDIO_COPY_STATIC_DATA=true
environment:
      - POSTGRES_HOST_AUTH_METHOD=false
      - POSTGRES_USER=${PG_USER}
      - POSTGRES_PASSWORD=${PG_PASS}
      - POSTGRES_DB=${PG_DB}

The problem was that I had the user and password set to “postgres” within the Label Studio section, and set to the variable PG_USER or PG_PASS in the Postgres section. I didn’t understand that these referred to the same thing and so should be set to the same thing.