Summary
Mattermost docker config does not seem to properly handle MM_SQLSETTINGS_DATASOURCE when pointing to a container/hist other than “postgres”
Steps to reproduce
On the host I’m trying to deploy mattermost, I already have an existing postgres container running (named “postgres”) When I first spun up mattermost, it tried and failed to connect to that container - i.e. in the logs, I saw that it used the docker network IP of that pre-existing postgres container.
So I saw this and modified my setup accordingly:
.env:
MM_SQLSETTINGS_DATASOURCE=postgres_mattermost://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10
docker-compose.yml:
services:
postgres_mattermost:
image: postgres:${POSTGRES_IMAGE_TAG}
...
mattermost:
depends_on:
- postgres_mattermost
...
environment:
- MM_SQLSETTINGS_DATASOURCE
(I also deleted all pertinent volume dirs from previous starts)
What I see in the mattermost container log now though is this:
{"timestamp":"2023-10-09 17:02:59.530 +02:00","level":"error","msg":"Failed to ping DB","caller":"sqlstore/store.go:252","error":"dial │
│ tcp 127.0.0.1:5432: connect: connection refused","retrying in seconds":10}
127.0.0.1:5432 is obviously wrong.
Expected behavior
With MM_SQLSETTINGS_DATASOURCE set as above, I’d excpect it to connect to my postgres_mattermost container.
Observed behavior
See above