Closed wilfriedroset closed 8 years ago
How to define a container link between gerrit & pg-gerrit like --link pg-gerrit:db
in compose?
DB_PORT_5432_TCP_ADDR: pg-gerrit
might not be a good idea to link gerrit to the database.
I've added the link between my two containers. According to the documentation it should be done with the directive links. I've updated my composefile using envvar replaced by gerrit-entrypoint.sh to get it running
version: '2' volumes: pg_data: gerrit_data: services: # docker run --name pg-gerrit -p 5432:5432 -e POSTGRES_USER=gerrit2 -e POSTGRES_PASSWORD=gerrit -e POSTGRES_DB=reviewdb -d postgres pg-gerrit: container_name: 'pg-gerrit' image: 'postgres:9.5.3' #restart: always ports: - '5432:5432' environment: POSTGRES_USER: gerrit2 POSTGRES_PASSWORD: gerrit POSTGRES_DB: reviewdb volumes: - '/etc/localtime:/etc/localtime:ro' - 'pg_data:/var/lib/postgresql/data' # docker run --name gerrit --link pg-gerrit:db -p 8080:8080 -p 29418:29418 -e DATABASE_TYPE=postgresql -d openfrontier/gerrit gerrit: container_name: 'gerrit' image: 'openfrontier/gerrit:2.11.x' #restart: always ports: - '8080:8080' - '29418:29418' environment: DATABASE_TYPE: postgresql DB_ENV_POSTGRES_DB: reviewdb DB_ENV_POSTGRES_PASSWORD: gerrit DB_ENV_POSTGRES_USER: gerrit2 DB_PORT_5432_TCP_ADDR: db links: - pg-gerrit:db volumes: - '/etc/localtime:/etc/localtime:ro' - 'gerrit_data:/var/gerrit/review_site'
Without _DB_ENV_POSTGRESDB, _DB_ENV_POSTGRESPASSWORD, _DB_PORT_5432_TCPADDR variables I can't start gerrit container.
Without _DB_ENV_POSTGRESDB, I've got
gerrit | fatal: DbInjector failed gerrit | fatal: Unable to determine SqlDialect gerrit | fatal: caused by org.postgresql.util.PSQLException: FATAL: database "db" does not exist
The configuration file generated looks like:
[database] type = postgresql database = db/ReviewDB hostname = db username = gerrit2
Without _DB_ENV_POSTGRESPASSWORD, I've got:
gerrit | fatal: DbInjector failed gerrit | fatal: Unable to determine SqlDialect gerrit | fatal: caused by org.postgresql.util.PSQLException: The server requested password-based authentication, but no password was provided.
The configuration file generated looks like:
[database] type = postgresql database = reviewdb hostname = db username = gerrit2
Without _DB_PORT_5432_TCPADDR, I've got:
gerrit | fatal: DbInjector failed gerrit | fatal: Unable to determine SqlDialect gerrit | fatal: caused by org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. gerrit | fatal: caused by java.net.ConnectException: Connection refused
The configuration file generated looks like:
grep database -A4 /var/lib/docker/volumes/gerrit_gerrit_data/_data/etc/gerrit.config [database] type = postgresql database = reviewdb username = gerrit2 hostname = localhost
The link environment variables reference is deprecated in version 2 of compose. So you have to define them in the compose file. But link is necessary unless you're using docker network. It seems that I'll have to think about how to support docker network in this image.
@wilfriedroset Here is an example I made recently to show the way of utilizing docker-compose, docker network and docker volume. It may be a helpful reference for this issue. Please let me know if your issue is solved then I can close this one.
Well detail compose file. Thanks!
When using a composefile to start postgres/gerrit, I end up with caused by java.net.UnknownHostException: pg-gerrit .
Docker images
Docker info
Error
Note: you might see the init of postgres the first time.
I don't get the error when running the two docker run manually or with different images. I think that tere is something wrong about the docker-compose file but I can't point the error. Any idea where I've done something wrong ?