tiredofit / docker-discourse

Dockerized web based forum software
MIT License
20 stars 6 forks source link

[WARN] ** [discourse] Postgres Host 'discourse-db' is not accessible, retrying.. #5

Open stephane-klein opened 1 year ago

stephane-klein commented 1 year ago

I have executed:

$ docker network create proxy
$ docker network create services
$ docker-compose up -d

I see:

$ docker-compose ps
           Name               Command   State                   Ports
-------------------------------------------------------------------------------------
discourse-app                 /init     Up      10050/tcp, 2020/tcp, 3000/tcp, 80/tcp
discourse-db                  /init     Up      10050/tcp, 2020/tcp, 5432/tcp
discourse-db-backup           /init     Up      10050/tcp, 2020/tcp
discourse-example-org-redis   /init     Up      10050/tcp, 2020/tcp, 6379/tcp

And:

$ docker-compose logs -f discourse-app
Attaching to discourse-app
discourse-app          |                                                                        ,---.
discourse-app          | ,--------.,--.                 ,--.            ,---.    ,--. ,--------.|   |
discourse-app          | '--.  .--'`--',--.--. ,---.  ,-|  |     ,---. /  .-'    |  | '--.  .--'|  .'
discourse-app          |    |  |   ,--.|  .--'| .-. :' .-. |    | .-. ||  `-,    |  |    |  |   |  |
discourse-app          |    |  |   |  ||  |   \   --.\ `-' |    ' '-' '|  .-'    |  |.--.|  |   `--'
discourse-app          |    `--'   `--'`--'    `----' `---'      `---' `--'      `--''--'`--'   .--.
discourse-app          |                                                                        '--'
discourse-app          | Image:  tiredofit/discourse | Version  3.1.4 Type 'image_changelog' for details
discourse-app          | Repository/Issues/Support:  https://github.com/tiredofit/docker-discourse/
discourse-app          |            Sponsor me for development and upkeep: https://www.tiredofit.ca/sponsor
discourse-app          |
discourse-app          | 2023-04-07.17:33:10 [NOTICE] ** [timezone] Timezone: Setting to 'America/Vancouver' from 'Etc/GMT'
discourse-app          | 2023-04-07.10:33:10 [NOTICE] ** [monitoring] Container configured for monitoring with 'zabbix modern'
discourse-app          | 2023-04-07.10:33:10 [NOTICE] ** [scheduling] Container configured for scheduled tasks with 'cron'
discourse-app          | 2023-04-07.10:33:10 [NOTICE] ** [messaging] Container configured to route mail via SMTP to 'postfix-relay'
discourse-app          | 2023-04-07.10:33:11 [NOTICE] ** [nginx] Disabling Nginx Functionality
discourse-app          | 2023-04-07.10:33:16 [WARN] ** [discourse] Postgres Host 'discourse-db' is not accessible, retrying.. (5 seconds so far)

...

discourse-app          | 2023-04-07.10:42:14 [WARN] ** [discourse] Postgres Host 'discourse-db' is not accessible, retrying.. (540 seconds so far)
discourse-app          | 2023-04-07.10:42:19 [WARN] ** [discourse] Postgres Host 'discourse-db' is not accessible, retrying.. (545 seconds so far)

Where is my mistake? How can I fix it?

tiredofit commented 1 year ago

It doesn't look like you have a functioning Postgresql database which is what it is waiting to verify..

stephane-klein commented 1 year ago

It doesn't look like you have a functioning Postgresql database which is what it is waiting to verify..

Indeed:

discourse-db           |                                                                        ,---.
discourse-db           | ,--------.,--.                 ,--.            ,---.    ,--. ,--------.|   |
discourse-db           | '--.  .--'`--',--.--. ,---.  ,-|  |     ,---. /  .-'    |  | '--.  .--'|  .'
discourse-db           |    |  |   ,--.|  .--'| .-. :' .-. |    | .-. ||  `-,    |  |    |  |   |  |
discourse-db           |    |  |   |  ||  |   \   --.\ `-' |    ' '-' '|  .-'    |  |.--.|  |   `--'
discourse-db           |    `--'   `--'`--'    `----' `---'      `---' `--'      `--''--'`--'   .--.
discourse-db           |                                                                        '--'
discourse-db           | Image:  tiredofit/postgres:15 | Version  15-3.0.2 Type 'image_changelog' for details
discourse-db           | Repository/Issues/Support:  https://github.com/tiredofit/docker-postgres/
discourse-db           |            Sponsor me for development and upkeep: https://www.tiredofit.ca/sponsor
discourse-db           |
discourse-db           | 2023-04-07.21:23:56 [NOTICE] ** [timezone] Timezone: Setting to 'America/Vancouver' from 'Etc/GMT'
discourse-db           | 2023-04-07.14:23:56 [NOTICE] ** [monitoring] Container configured for monitoring with 'zabbix modern'
discourse-db           | 2023-04-07.14:23:56 [NOTICE] ** [scheduling] Container configured for scheduled tasks with 'cron'
discourse-db           | 2023-04-07.14:23:56 [ERROR] ** [postgres] No 'Superuser Password' Entered! - Set '$SUPERUSER_PASS'
discourse-db           | **********************************************************************************************************************
discourse-db           | **********************************************************************************************************************
discourse-db           | ****                                                                                                              ****
discourse-db           | ****       ERROR - Some initialization scripts haven't completed - All services are now halted                    ****
discourse-db           | ****             - The following scripts in '/etc/cont-init.d' did not pass their completion check                ****
discourse-db           | ****                                                                                                              ****
discourse-db           | **********************************************************************************************************************
discourse-db           | **********************************************************************************************************************
discourse-db           |
discourse-db           | 10-postgres
discourse-db           |
discourse-db           |
discourse-db           | **********************************************************************************************************************
discourse-db           | **********************************************************************************************************************
discourse-db           | ****                                                                                                              ****
discourse-db           | ****       This could have happened for a variety of reasons. Please make sure you have followed the README       ****
discourse-db           | ****       relating to this image and have proper configuration such as environment variables and volumes set     ****
discourse-db           | ****                                                                                                              ****
discourse-db           | ****       If you feel that you have encountered a bug, please submit an issue on the revision control system     ****
discourse-db           | ****       and provide full debug logs by setting the environment variable 'DEBUG_MODE=TRUE'                      ****
discourse-db           | ****                                                                                                              ****
discourse-db           | **********************************************************************************************************************
discourse-db           | **********************************************************************************************************************
discourse-db           |
discourse-db           | Image: tiredofit/postgres:15
discourse-db           | Repository/Issues/Support: https://github.com/tiredofit/docker-postgres/
stephane-klein commented 1 year ago

@tiredofit Fixed by:

❯ git diff
diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
index 852c9fe..df9cd83 100644
--- a/examples/docker-compose.yml
+++ b/examples/docker-compose.yml
@@ -45,6 +45,7 @@ services:
       - POSTGRES_DB=discourse
       - POSTGRES_USER=discourse
       - POSTGRES_PASSWORD=password
+      - SUPERUSER_PASS=superuser
     networks:
       - services
Nicolab commented 1 year ago

If it helps, I solved by adding the - SUPERUSER_PASS=superuser like @stephane-klein Also by using the official Postgres image and exposing the PG port. Without that, PG is not reachable.

discourse-db:
    container_name: discourse-db
    image: postgres:15
    restart: unless-stopped
    volumes:
      - ./db:/var/lib/postgresql/data
    environment:
      - TIMEZONE=Europe/Paris
      - CONTAINER_NAME=discourse-db

      - POSTGRES_DB=discourse
      - POSTGRES_USER=discourse
      - POSTGRES_PASSWORD=password
      - SUPERUSER_PASS=superuser
    networks:
      - services
    expose:
      - 5432