Compare commits
2 commits
048f32f8d8
...
02a3a7d8c1
Author | SHA1 | Date | |
---|---|---|---|
02a3a7d8c1 | |||
1b6e67dba6 |
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
version: '3.7'
|
version: '3.7'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
# You need to create this network manually first!
|
||||||
|
synapse:
|
||||||
|
external: true
|
||||||
|
|
||||||
services:
|
services:
|
||||||
synapse:
|
synapse:
|
||||||
# https://hub.docker.com/r/matrixdotorg/synapse
|
# https://hub.docker.com/r/matrixdotorg/synapse
|
||||||
# https://github.com/matrix-org/synapse/tree/master/docker
|
# https://github.com/matrix-org/synapse/tree/master/docker
|
||||||
image: "matrixdotorg/synapse:${IMAGE_VERSION:-latest}"
|
image: "matrixdotorg/synapse:${IMAGE_VERSION:-latest}"
|
||||||
container_name: synapse
|
container_name: synapse
|
||||||
# This way we'll be able to access PostgreSQL on local machine using 'localhost' when it's listening only locally.
|
hostname: synapse
|
||||||
network_mode: host
|
extra_hosts:
|
||||||
|
- 'host.docker.internal:host-gateway'
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
- synapse
|
||||||
ports:
|
ports:
|
||||||
- "${INTERFACE_EXT:-127.0.0.1}:${HTTP_PORT_EXT:-8008}:${HTTP_PORT_INT:-8008}/tcp"
|
- "${INTERFACE_EXT:-127.0.0.1}:${HTTP_PORT_EXT:-8008}:${HTTP_PORT_INT:-8008}/tcp"
|
||||||
volumes:
|
volumes:
|
||||||
|
|
Loading…
Reference in a new issue