Using PostgreSQL on host machine from Synapse container in a more isolated way. #25
|
@ -21,6 +21,11 @@ docker-compose logs -f
|
||||||
Some services may require additional configuration. Check for additional `README.md` files
|
Some services may require additional configuration. Check for additional `README.md` files
|
||||||
or comments in the `docker-compose.yml` files or `.env.dist` templates.
|
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?
|
## Is it working?
|
||||||
|
|
||||||
Not every stack is tested to fully work.
|
Not every stack is tested to fully work.
|
||||||
|
|
37
_docs/access_database_on_host_from_docker.md
Normal file
37
_docs/access_database_on_host_from_docker.md
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# 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`:
|
||||||
|
```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 in 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 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.
|
|
@ -10,7 +10,10 @@ docker-compose run synapse generate
|
||||||
|
|
||||||
After that you can edit `./data/homeserver.yaml` according to your needs.
|
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
|
# Running the server
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue