openfrontier / docker-gerrit

Build a Docker image with the Gerrit code review system
Apache License 2.0
197 stars 116 forks source link

[ Question ] Stuck on "Waiting for DB connection..." #109

Closed ShonInDim closed 6 years ago

ShonInDim commented 6 years ago

I trying to start docker-gerrit container with external PostgresDB (running on localhost) and it's only hanging on DB connection nothing more happened.

Doing like :

  1. clone repo; build image from Dockerfile.

  2. run container from image

    • docker run --name gerrit \
    • -p 8081:8081 \
    • -p 29418:29418 \
    • -e WEBURL=http://173.***.***.***:8081 \
    • -e DATABASE_TYPE=postgresql \
    • -e DB_PORT_5432_TCP_ADDR=127.0.0.1 \
    • -e DB_PORT_5432_TCP_PORT=5432 \
    • -e DB_ENV_POSTGRES_DB=reviewdb \
    • -e DB_ENV_POSTGRES_USERE=gerrit2 \
    • -e DB_ENV_POSTGRES_PASSWORD=gerrit \
    • -d gerritpenfro `
  3. docker logs -f gerrit Generating SSH host key ... rsa... dsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done Initialized /var/gerrit/review_site /gerrit-entrypoint.sh: ignoring /docker-entrypoint-init.d/* Waiting for database connection 127.0.0.1:5432...

  4. while DB running on

    • tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 9507/postgres
    • tcp6 0 0 ::1:5432 :::* LISTEN 9507/postgres
    • udp6 16896 0 ::1:44157 ::1:44157 ESTABLISHED 9507/postgres

& has a valid user gerrit2 with password respectively.

Could you give me advice what exactly should I do to run gerrit within container and external existing Postgres DB ? May be I doing something wrong ? Thank you in advance.

thinkernel commented 6 years ago

Would you please try DATABASE_DATABASE, DATABASE_HOSTNAME, DATABASE_PASSWORD, DATABASE_USERNAME then tell me tell what happens?

ShonInDim commented 6 years ago

Would you please try DATABASE_DATABASE, DATABASE_HOSTNAME, DATABASE_PASSWORD, DATABASE_USERNAME then tell me tell what happens?

Sure, I can try it later today. But I thought DATABASE_DATABASE, DATABASE_HOSTNAME, DATABASE_PASSWORD, DATABASE_USERNAME used in case of DB as separate container, isn't it ?

ShonInDim commented 6 years ago

DATABASE_DATABASE is it name of my local DB, right ?

So I tried :

docker run --name gerrit

docker logs -f gerrit :

ls: /var/gerrit/review_site/git: No such file or directory First time initialize gerrit... [2018-11-06 17:57:57,531] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /var/gerrit/review_site/etc/gerrit.config; assuming defaults Generating SSH host key ... rsa... dsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done Initialized /var/gerrit/review_site

/gerrit-entrypoint.sh: ignoring /docker-entrypoint-init.d/*

Waiting for database connection 127.0.0.1:5432 ...

same result, as early. I have no clue what could be cause of this problem. When I connect to review DB manually as user it's work fine, but from container it's not. Guess cause of this issue DB itself, but can not figure out what\where exactly.

ShonInDim commented 6 years ago

as I thought this issue linked with docker networking; if add --net=host key:value param docker-gerrit container successfully connected to local Postgres db. Now I have another problem with db schema, but it's another separate case, so I do it on my own.

thinkernel commented 6 years ago

Glad to hear that you have solved this issue. Those DB* environment variables are designed to work with docker --link which is kind of legacy. That's why DATABASE* environment variables are introduced. These environment variables can be used with any kind of external databases, containerized or not.