New docker image ignores environment variables

New docker image mattermost/mattermost-enterprise-edition ignores environment variables like POSTGRES_USER, POSTGRES_PASSWORD, DB_HOST etc…
I pass the variables to docker image but mattermost still trying to connect to default db host (127.0.0.1) I’ve checked the variables are present in container.

While old image mattermost/mattermost-prod-app works correctly

So config is totally the same, different images works differently, the old one uses environment variables, the new one not.

Easy to reproduce:

$ docker run --rm -p 8065:8065 --env DB_HOST=1.1.1.1 --env MM_USERNAME=mmuser --env MM_PASSWORD=123 --env MM_DBNAME=mattermost mattermost/mattermost-enterprise-edition:6.1 mattermost

{“timestamp”:“2022-01-31 08:16:22.501 Z”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:271”,“error”:“dial tcp 127.0.0.1:5432: connect: connection refused”,“retrying in seconds”:10}

as we can see it tries 127.0.0.1:5432

checking env vars:

$ docker exec 0cea660b3084 env

PATH=/mattermost/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=0cea660b3084
MM_DBNAME=mattermost
DB_HOST=1.1.1.1
MM_USERNAME=mmuser
MM_PASSWORD=123
HOME=/mattermost

DB_HOST=1.1.1.1

New image uses MM_SQLSETTINGS_DATASOURCE env var :grimacing:

this is ignored as well, resulting in the default string being inserted in the config.json:

"SqlSettings": {
        "DriverName": "postgres",
        "DataSource": "postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable\u0026connect_timeout=10",
        "DataSourceReplicas": [],
        "DataSourceSearchReplicas": [],
        "MaxIdleConns": 20,
        "ConnMaxLifetimeMilliseconds": 3600000,
        "MaxOpenConns": 300,
        "Trace": false,
        "AtRestEncryptKey": "{{{redacted}}}",
        "QueryTimeout": 30,
        "DisableDatabaseSearch": false
    },