openfrontier / docker-gerrit

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

Dockerfile and examples geared towards deprecated --link feature of docker #93

Closed giftig closed 5 years ago

giftig commented 6 years ago

This appears repeatedly in the log when I run gerrit with postgres, while postgres is still initialising:

gerrit_1    | Usage: nc [OPTIONS] HOST PORT  - connect
gerrit_1    | nc [OPTIONS] -l -p PORT [HOST] [PORT]  - listen
gerrit_1    |
gerrit_1    |   -e PROG Run PROG after connect (must be last)
gerrit_1    |   -l  Listen mode, for inbound connects
gerrit_1    |   -lk With -e, provides persistent server
gerrit_1    |   -p PORT Local port
gerrit_1    |   -s ADDR Local address
gerrit_1    |   -w SEC  Timeout for connects and final net reads
gerrit_1    |   -i SEC  Delay interval for lines sent
gerrit_1    |   -n  Don't do DNS resolution
gerrit_1    |   -u  UDP mode
gerrit_1    |   -v  Verbose
gerrit_1    |   -o FILE Hex dump traffic
gerrit_1    |   -z  Zero-I/O mode (scanning)

This is presumably related to this line:

gerrit-entrypoint.sh
14:  until nc -z $1 $2; do

I don't see the line prior to that statement being echoed, but I'm guessing that's simply being swallowed elsewhere as I'm observing this while postgres is still initialising, which is what that line is waiting for.

I don't have time to build my own image with some debugging to find out what's caused the error right now, but if I get chance later I'll see if I can debug it further. The obvious answer is that either $DB_PORT_5432_TCP_ADDR or ${DB_PORT_5432_TCP_PORT} is unset in the script, though since it eventually stops polling, it still seems to be noticing that postgres is up somehow.

thinkernel commented 6 years ago

DB_PORT_5432_TCP_ADDR and DB_PORT_5432_TCP_PORT are necessary when running with postgres. Depends on the way you start your containers, these environment variables will be generated when you use the docker --link way as described in the README. Otherwise, you have to set it by yourself.

giftig commented 6 years ago

Ah I see, they're docker env variables referring to the image DB when they're linked via the legacy method. I was initially curious how the correct container was discovered by gerrit, given that the example showed no configuration passed to the gerrit image.

In that case, the issue is really that the Dockerfile is geared specifically towards using the legacy link feature of docker rather than networks, and doesn't provide any real means of configuring the postgres target properly.

giftig commented 6 years ago

Updated the title accordingly.

giftig commented 6 years ago

Looks like it's a duplicate of #64.

I'll close and create my own image instead. Thanks.

thinkernel commented 6 years ago

Although docker —link compatable has to be supported until docker and kubernetes stop supporting this feature, it’s time to move on to a more descriptive name while keeping the old one supported.

thinkernel commented 6 years ago

Hi @giftig I add another way to connect with external database. It has been included in the latest image and will be released when Gerrit release another version. Let me know if it works for you, please.