Documentation regarding using the database running on the host machine.

This commit is contained in:
Alexey Skobkin 2022-03-19 04:11:41 +03:00
parent aca78fc57d
commit ff0df0148c
3 changed files with 48 additions and 1 deletions

View file

@ -21,6 +21,11 @@ docker-compose logs -f
Some services may require additional configuration. Check for additional `README.md` files
or comments in the `docker-compose.yml` files or `.env.dist` templates.
## Using a database server on the host from the container
You need to change your database configuration to be able to do that. Check
[this](_docs/access_database_on_host_from_docker.md) documentation.
## Is it working?
Not every stack is tested to fully work.

View file

@ -0,0 +1,39 @@
# Using database on host machine from Docker
## Database configuration
### PostgreSQL
You need to make PostgreSQL listen not only `localhost`, but also Docker's network interface.
To do that you need to add host machine IP address in the Docker network (usually `172.17.0.1`) to the
`postgresql.conf` by changing `listen_addresses` parameter:
```ini
# Listen local interface and also Docker's network
listen_addresses = 'localhost,172.17.0.1'
```
Then you need to allow apps inside Docker containers to authenticate. That could be done by adding following line to the
`pg_hba.conf`:
```
# Docker network
host all all 172.17.0.0/12 md5
```
Do not forget to restart your PostgreSQL server. For PostgreSQL 12 and `main` cluster it could be usually done like that:
```shell
systemctl restart postgresql@12-main.service
```
### MySQL / MariaDB
TBW
## Application configuration inside Docker
Stacks which allow to use external database back-end should also map `host.docker.internal` to the host machine
address inside Docker's default network.
So to connect to the database from the application inside the container you should use `host.docker.internal` as the
database host/address.

View file

@ -10,7 +10,10 @@ docker-compose run synapse generate
After that you can edit `./data/homeserver.yaml` according to your needs.
If you want to use full-fledged PostgreSQL instead of SQLite, you can check [this documentation](https://github.com/matrix-org/synapse/blob/master/docs/postgres.md).
If you want to use full-fledged PostgreSQL instead of SQLite, you can check
[this documentation](https://github.com/matrix-org/synapse/blob/master/docs/postgres.md).
To use PostgreSQL running on the host machine, use [this](../_docs/access_database_on_host_from_docker.md) configuration.
# Running the server