From 8e9fed3c072b58a580c8a070fe975203e44f3a93 Mon Sep 17 00:00:00 2001 From: doublebyte1 Date: Tue, 12 Dec 2017 13:01:47 +0100 Subject: [PATCH] - Updated documentation about how-to connect geonetwork to a postgres database, avoiding references to localhost. Only two use cases are presented: - connecting to an existing external database instance (using dns) - connecting to a postgres container by name (full reproducible example is presented) --- geonetwork/variant-postgres.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/geonetwork/variant-postgres.md b/geonetwork/variant-postgres.md index e84e36820..5b0f5b683 100644 --- a/geonetwork/variant-postgres.md +++ b/geonetwork/variant-postgres.md @@ -10,15 +10,16 @@ If your postgres instance is listening on a non-standard port, you must also set ### Connecting to a postgres database -If you want to connect to a postgres server, you need to pass an extra environment variable, containing the IP address for this server (which could be localhost, if you are running it locally). - `POSTGRES_DB_HOST`: IP address of your database server +If you want to connect to a postgres server, you need to pass an extra environment variable, `POSTGRES_DB_HOST`, +containing the address of this server. -For instance, if the server is running on `192.168.1.10`, on port `5434`, the username is `postgres` and the password is `mysecretpassword`: +If you want to connect to an **external database server**, you can use either the IP address or the DNS as `POSTGRES_DB_HOST`. For instance, if the server is running on `mydns.net`, on port `5434`, the username is `postgres` and the password is `mysecretpassword`: ```console -$ docker run --name geonetwork -d -p 8080:8080 -e POSTGRES_DB_HOST=192.168.1.10 -e POSTGRES_DB_PORT=5434 -e POSTGRES_DB_USERNAME=postgres -e POSTGRES_DB_PASSWORD=mysecretpassword geonetwork:postgres +$ docker run --name geonetwork -d -p 8080:8080 -e POSTGRES_DB_HOST=mydns.net -e POSTGRES_DB_PORT=5434 -e POSTGRES_DB_USERNAME=postgres -e POSTGRES_DB_PASSWORD=mysecretpassword geonetwork:postgres ``` -If you want to use the container name as `POSTGRES_DB_HOST`, just make sure that containers can discover each other, by **running them in the same user-defined network**. For instance, you can create a bridge network: +If are want to **run postgres on a container**, you can use the container name as `POSTGRES_DB_HOST`: just make sure that containers can discover each other, by **running them in the same user-defined network**. For instance, you can create a bridge network: ```console $ docker network create --driver bridge mynet