Mattermost - docker - linux - postgresql user error

Docker containers starts with docker-compose -f mattermost-compose.yml -f mattermost-without-nginx-compose.yml up -d, but I’m constantly getting postgresql errors with:

1st time (using this: container_name: ${APPNAME}_container_name: postgres):
mattermost_mattermost | {“timestamp”:“2023-01-29 22:42:29.855 +01:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:248”,“error”:“pq: Could not detect default username. Please provide one explicitly”,“retrying in seconds”:10}

2nd time after editing compose and .env (I deleted a variable from container_name: ${APPNAME}_container_name: postgres > container_name: container_name: postgres
{“timestamp”:“2023-01-30 00:22:33.588 +01:00”,“level”:“info”,“msg”:“Pinging SQL”,“caller”:“sqlstore/store.go:238”,“database”:“master”}
{“timestamp”:“2023-01-30 00:22:33.588 +01:00”,“level”:“error”,“msg”:“Failed to ping DB”,“caller”:“sqlstore/store.go:248”,“error”:“parse "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10": net/url: invalid userinfo”,“retrying in seconds”:10}

Steps to reproduce
Following installation steps here: Install Mattermost via Docker — Mattermost documentation

Expected behavior
Containers are running and services are up without errors

Observed behavior
relevant compose part:

    image: postgres:${POSTGRES_IMAGE_TAG}
    container_name: postgres
    restart: ${RESTART_POLICY}
    user: "${UID}:${GID}"
    mem_limit: ${MEM_POSTGRES}
      - .env
      - no-new-privileges:true
    pids_limit: 100
    read_only: true
      - /tmp
      - /var/run/postgresql
      - ${POSTGRES_DATA_PATH}:/var/lib/postgresql/data
      # timezone inside container
      - TZ=${TZ}
      # necessary Postgres options/variables

relevant .env parts:


Hi Alexander and welcome to the Mattermost forums!

I’ve never seen these specific error messages, so I’m not 100% sure what exactly the problem is.
As you can see in the .env file, the variable MM_SQLSETTINGS_DATASOURCE is generated with the values of the other variables and if your docker-compose version is too old, it will not support variable substitution inside the .env file
To verify that this is your problem you could modify the .env file to not use the variables but the values instead:


If this works, then my assumption is correct and you would just need to update your docker-compose binary.

Hi Alexander! :slight_smile:

Yeah I made an hour long Google search before I posted and I did not find any similar problem.
I tried the way you described above, but still… :confused:

{"timestamp":"2023-01-30 08:29:39.152 +01:00","level":"info","msg":"Server is initializing...","caller":"platform/service.go:165","go_version":"go1.18.1"}
{"timestamp":"2023-01-30 08:29:39.152 +01:00","level":"info","msg":"Pinging SQL","caller":"sqlstore/store.go:238","database":"master"}
{"timestamp":"2023-01-30 08:29:39.153 +01:00","level":"error","msg":"Failed to ping DB","caller":"sqlstore/store.go:248","error":"pq: Could not detect default username. Please provide one explicitly","retrying in seconds":10}
{"timestamp":"2023-01-30 08:29:49.158 +01:00","level":"info","msg":"Pinging SQL","caller":"sqlstore/store.go:238","database":"master"}
{"timestamp":"2023-01-30 08:29:49.158 +01:00","level":"error","msg":"Failed to ping DB","caller":"sqlstore/store.go:248","error":"pq: Could not detect default username. Please provide one explicitly","retrying in seconds":10}

Anyway the versions are:
Docker version 20.10.12, build 20.10.12-0ubuntu2~20.04.1
docker-compose version 1.25.0, build unknown
(inside the compose the default 2.4)

Did I miss maybe any step regarding to postgres?

Thank you for your help!

Now I tried to start over again the whole deployment process with minimal modification. You should be right, because passing through variables inside .env did not work again, after removing variables and give exact data it started. Based on my versions from the previous reply, which one is bad? I mean which release allows you to use variables inside .env?

Thank you!

Anything above 1.25, actually - so it’s exactly the version that ships with Debian and Ubuntu that is outdated and does not support that.

You can use these commands to update to the latest available docker-compose version:

DC=$(which docker-compose)
wget -qO $
chmod 755 $
mv $DC $DC.old
mv $ $DC