certat / do-portal

This project is in maintenance mode and will only receive bug fixes, but no new features. A new version of this software is being developed.
5 stars 5 forks source link

Docker: postgres is unavailable - wrong hostname used? #119

Open ghost opened 4 years ago

ghost commented 4 years ago

Branch master 532dab952d9e4f09ae99826b0b9138a523fcd613

sebastianw@medan do-portal (master %)$ sudo docker-compose up
[sudo] password for root: 
WARNING: Found orphan containers (epplication-db, epplication-app, epplication-selenium) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Starting epplication_db       ... done
Recreating portal-db          ... done
Recreating portal-frontend    ... done
Starting epplication_selenium ... done
Starting epplication_app      ... done
Recreating portal-backend     ... done
Recreating proxy              ... done
Attaching to epplication_db, epplication_selenium, portal-db, epplication_app, portal-frontend, portal-backend, proxy
epplication_db          | 
epplication_db          | PostgreSQL Database directory appears to contain a database; Skipping initialization
epplication_app         | psql: could not translate host name "epplication-db" to address: Name or service not known
portal-backend          | /home/cert/do-portal/config.cfg
epplication_selenium    | 2020-04-06 10:08:07,091 INFO Included extra file "/etc/supervisor/conf.d/selenium-debug.conf" during parsing
epplication_selenium    | 2020-04-06 10:08:07,091 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
portal-db               | 
portal-db               | PostgreSQL Database directory appears to contain a database; Skipping initialization
portal-db               | 
epplication_app         | Postgres is unavailable - sleeping
epplication_db          | 
epplication_db          | LOG:  database system was shut down at 2020-04-06 10:04:53 UTC
portal-db               | LOG:  database system was shut down at 2020-04-06 10:04:53 UTC
epplication_app         | psql: could not translate host name "epplication-db" to address: Name or service not known
epplication_db          | LOG:  MultiXact member wraparound protections are now enabled
portal-backend          | Postgres is up - check schema
portal-frontend         | bash: ./docker_entrypoint.sh: No such file or directory
epplication_db          | LOG:  database system is ready to accept connections
epplication_db          | LOG:  autovacuum launcher started
portal-db               | LOG:  MultiXact member wraparound protections are now enabled
portal-db               | LOG:  database system is ready to accept connections
proxy                   | Custom dhparam.pem file found, generation skipped
epplication_app         | Postgres is unavailable - sleeping
portal-backend          |  * Running on http://0.0.0.0:8081/ (Press CTRL+C to quit)
epplication_selenium    | 2020-04-06 10:08:07,095 INFO supervisord started with pid 8
proxy                   | forego     | starting dockergen.1 on port 5000
proxy                   | forego     | starting nginx.1 on port 5100
portal-db               | LOG:  autovacuum launcher started
proxy                   | dockergen.1 | 2020/04/06 10:08:12 Generated '/etc/nginx/conf.d/default.conf' from 6 containers
proxy                   | dockergen.1 | 2020/04/06 10:08:12 Running 'nginx -s reload'
epplication_selenium    | 2020-04-06 10:08:08,097 INFO spawned: 'xvfb' with pid 11
portal-frontend exited with code 127
epplication_app         | psql: could not translate host name "epplication-db" to address: Name or service not known
proxy                   | dockergen.1 | 2020/04/06 10:08:12 Watching docker events
epplication_app         | Postgres is unavailable - sleeping
proxy                   | dockergen.1 | 2020/04/06 10:08:12 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
epplication_selenium    | 2020-04-06 10:08:08,099 INFO spawned: 'fluxbox' with pid 12
epplication_selenium    | 2020-04-06 10:08:08,100 INFO spawned: 'vnc' with pid 13
epplication_selenium    | 2020-04-06 10:08:08,102 INFO spawned: 'selenium-standalone' with pid 14
epplication_app         | psql: could not translate host name "epplication-db" to address: Name or service not known
epplication_selenium    | 2020-04-06 10:08:08,473 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
epplication_app         | Postgres is unavailable - sleeping
epplication_selenium    | 2020-04-06 10:08:08,473 INFO success: fluxbox entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
epplication_selenium    | 2020-04-06 10:08:08,473 INFO success: vnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
epplication_selenium    | 2020-04-06 10:08:08,473 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
epplication_selenium    | 10:08:09.071 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
epplication_selenium    | 10:08:09.284 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
epplication_selenium    | 2020-04-06 10:08:09.353:INFO::main: Logging initialized @1191ms to org.seleniumhq.jetty9.util.log.StdErrLog
epplication_selenium    | 10:08:09.808 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
epplication_selenium    | 10:08:10.028 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
epplication_app         | psql: could not translate host name "epplication-db" to address: Name or service not known
epplication_app         | Postgres is unavailable - sleeping
epplication_app         | psql: could not translate host name "epplication-db" to address: Name or service not known
epplication_app         | Postgres is unavailable - sleeping
[...]

The install documentation says:

https://github.com/certat/do-portal/blob/532dab952d9e4f09ae99826b0b9138a523fcd613/docs/01_INSTALL.md#edit-etchosts-file

127.0.0.1 epplication_app

whereas the script seems to use epplication-db.

I guess either the hostname in docker should be fixed (preferred) or the documentation updated

davewood commented 4 years ago

to clear things up

the /etc/hosts entry 127.0.0.1 epplication_app is there to make sure requests on the docker host machine go to the right docker-container (in this case the epplication web app)

epplication-db is the hostname of the postgres db docker-container and the script you are refering to is probably running in one of the docker containers and uses this value to connect to the database.

The message Postgres is unavailable - sleeping is from the docker startup script that is waiting for the docker postgres container to become available. (https://github.com/certat/do-portal/blob/devel/backend/docker_entrypoint.sh#L26)

the problem you are experiencing should be fixed by now. if not please let me know.