- 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)
This commit is contained in:
doublebyte1 2017-12-12 13:01:47 +01:00
parent e853f8a4e9
commit 8e9fed3c07
1 changed files with 5 additions and 4 deletions

View File

@ -10,15 +10,16 @@ If your postgres instance is listening on a non-standard port, you must also set
### Connecting to a postgres database ### 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 ```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 ```console
$ docker network create --driver bridge mynet $ docker network create --driver bridge mynet