# Mattermost - docker - linux - postgresql user error

**URL:** <https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943>\
**Category:** Troubleshooting\
**Created:** [January 29, 2023, 11:36pm UTC](https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943 "2023-01-29T23:36:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexander\_taylr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/alexander_taylr/32/6317_2.png) [@alexander\_taylr](https://forum.mattermost.com/u/alexander_taylr)\
**Post date:** [January 29, 2023, 11:36pm UTC](https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943/1 "2023-01-29T23:36:21Z")

</div>

**Summary**  
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](https://docs.mattermost.com/install/install-docker.html)

**Expected behavior**  
Containers are running and services are up without errors

**Observed behavior**  
**relevant compose part:**

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

```

**relevant .env parts:**

```auto
POSTGRES_IMAGE_TAG=13-alpine
POSTGRES_DATA_PATH=./volumes/db/var/lib/postgresql/data
POSTGRES_USER=mydbuser
POSTGRES_PASSWORD=mydbpw1234
POSTGRES_DB=mattermost

```

```auto
MM_SQLSETTINGS_DRIVERNAME=postgres
MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10

```

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [January 30, 2023, 3:46am UTC](https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943/2 "2023-01-30T03:46:38Z")

</div>

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:

```auto
MM_SQLSETTINGS_DATASOURCE=postgres:/mydbuser:mydbpw1234@postgres:5432/mattermost?sslmode=disable&connect_timeout=10

```

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

---

<div class="post-metadata">

**Author:** ![alexander\_taylr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/alexander_taylr/32/6317_2.png) [@alexander\_taylr](https://forum.mattermost.com/u/alexander_taylr)\
**Post date:** [January 30, 2023, 7:51am UTC](https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943/3 "2023-01-30T07:51:54Z")

</div>

> [@agriesser](#):
>
> ```auto
> MM_SQLSETTINGS_DATASOURCE=postgres:/mydbuser:mydbpw1234@postgres:5432/mattermost?sslmode=disable&connect_timeout=10
> 
> ```

Hi Alexander! 🙂

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… 😕

```auto
{"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!

---

<div class="post-metadata">

**Author:** ![alexander\_taylr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/alexander_taylr/32/6317_2.png) [@alexander\_taylr](https://forum.mattermost.com/u/alexander_taylr)\
**Post date:** [January 30, 2023, 8:28am UTC](https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943/4 "2023-01-30T08:28:47Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [January 30, 2023, 8:32am UTC](https://forum.mattermost.com/t/mattermost-docker-linux-postgresql-user-error/14943/5 "2023-01-30T08:32:05Z")

</div>

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:

```auto
DC=$(which docker-compose)
wget -qO $DC.new https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64
chmod 755 $DC.new
mv $DC $DC.old
mv $DC.new $DC

```
