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
Expected behavior
Containers are running and services are up without errors
Observed behavior
relevant compose part:
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:
POSTGRES_IMAGE_TAG=13-alpine
POSTGRES_DATA_PATH=./volumes/db/var/lib/postgresql/data
POSTGRES_USER=mydbuser
POSTGRES_PASSWORD=mydbpw1234
POSTGRES_DB=mattermost
MM_SQLSETTINGS_DRIVERNAME=postgres
MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10