https://supertokens.com/ logo
Docker compose issue
a

arnmishra

03/13/2023, 6:01 PM
Hi all, I'm trying to get my docker compose to run properly but have been facing the following error. Not sure why it can't detect the correct password/database:
2023-03-13 10:58:32 2023-03-13 17:58:32.193 UTC [119] FATAL:  password authentication failed for user "doss-local"
2023-03-13 10:58:32 2023-03-13 17:58:32.193 UTC [119] DETAIL:  Password does not match for user "doss-local".
2023-03-13 10:58:32     Connection matched pg_hba.conf line 99: "host all all all md5"
2023-03-13 10:58:35 2023-03-13 17:58:35.638 UTC [129] FATAL:  database "doss-local" does not exist
with the following docker compose:
version: '3.8'
services:
  doss-postgres-local:
    platform: linux/amd64
    container_name: doss-postgres-local
    image: postgis/postgis:12-3.3
    environment:
      POSTGRES_USER: doss-local
      POSTGRES_PASSWORD: doss-password
      POSTGRES_DB: doss-localdb
      PGDATA: /var/lib/postgresql/data
    ports:
      - 5432:5432
    networks:
      - app_network
    volumes:
      - doss-localdb:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ['CMD', 'pg_isready', '-U', 'doss-local']
      interval: 5s
      timeout: 5s
      retries: 5
    cap_add:
      - NET_ADMIN

  supertokens:
    image: registry.supertokens.io/supertokens/supertokens-postgresql:4.4
    depends_on:
      doss-postgres-local:
        condition: service_healthy
    ports:
      - 3567:3567
    environment:
      POSTGRESQL_CONNECTION_URI: 'postgresql://doss-local:doss-password@doss-postgres-local:5432/doss-localdb'
    networks:
      - app_network
    restart: unless-stopped
    healthcheck:
      test: >
        bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e "GET /hello HTTP/1.1\r\nhost: 127.0.0.1:3567\r\nConnection: close\r\n\r\n" >&3 && cat <&3 | grep "Hello"'
      interval: 10s
      timeout: 5s
      retries: 5
r

rp

03/14/2023, 5:07 AM
Hey @arnmishra
You are using doss-local instead of doss-postgres-local
a

arnmishra

03/14/2023, 4:49 PM
hm? The user is supposed to be doss-local right? That’s what
POSTGRES_USER
is
I tried changing all instances of doss-local to doss-postgres-local just to test and it still doesn’t work with the same error.
I updated the dockerfile in the initial post with
doss-username
as the username to make it easier to parse through (and updated the error message as well)
hallelujah! figured it out with some help from chat gpt 4. for some reason the roles were actually just not being created - the solution was to remove the dashes from the username, password, and db names and now it works?
updated (functional) docker-compose:
version: '3.8'
services:
  doss-postgres-local:
    platform: linux/amd64
    container_name: doss-postgres-local
    image: postgis/postgis:12-3.3
    environment:
      POSTGRES_USER: dossUsername
      POSTGRES_PASSWORD: dossPassword
      POSTGRES_DB: dossLocaldb
      PGDATA: /var/lib/postgresql/data
    ports:
      - 5432:5432
    networks:
      - app_network
    volumes:
      - dossLocaldb:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U doss-username']
      interval: 5s
      timeout: 5s
      retries: 5
    cap_add:
      - NET_ADMIN

  supertokens:
    image: registry.supertokens.io/supertokens/supertokens-postgresql:4.4
    depends_on:
      doss-postgres-local:
        condition: service_healthy
    ports:
      - 3567:3567
    environment:
      POSTGRESQL_CONNECTION_URI: 'postgresql://dossUsername:dossPassword@doss-postgres-local:5432/dossLocaldb'
    networks:
      - app_network
    restart: unless-stopped
    healthcheck:
      test: >
        bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e "GET /hello HTTP/1.1\r\nhost: 127.0.0.1:3567\r\nConnection: close\r\n\r\n" >&3 && cat <&3 | grep "Hello"'
      interval: 10s
      timeout: 5s
      retries: 5
r

rp

03/15/2023, 5:16 AM
oh awesome!