# Setting up using Docker

**URL:** <https://forum.mattermost.com/t/setting-up-using-docker/13891>\
**Category:** Troubleshooting\
**Created:** [August 19, 2022, 1:06pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891 "2022-08-19T13:06:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 1:06pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/1 "2022-08-19T13:06:11Z")

</div>

I am making a Mattermost server and doing it via Docker-Compose. I am getting the following error message.

> Error: failed to load configuration: failed to create store: unable to load on store creation: invalid config: Config.IsValid: Site URL must be a valid URL and start with http:// or https://., parse “https://${DOMAIN}”: invalid character “{” in host name

Any idea why?

---

<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:** [August 19, 2022, 1:20pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/2 "2022-08-19T13:20:56Z")

</div>

Hi JPzone282 and welcome to the Mattemost forums!

Your docker-compose version is too old and therefore unable to replace the variables (in this case ${DOMAIN}) with the real values in the configuration option.  
You will need to upgrade to a recent docker version and use the compose plugin (`docker compose` instead of `docker-compose`) if you cannot upgrade to a newer `docker-compose` version.

Alternatively, you can just fix the entries in the `.env` file manually.  
You did specify your mattermost domain in the second line of the `.env` file already, search in this file for other occurences of the string `${DOMAIN}` and replace it with your domainname too, so that no variables are being used.

You will also have to do that with the other variables in the file, like `${POSTGRES_USER}`, etc.

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 2:03pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/3 "2022-08-19T14:03:15Z")

</div>

Hi agriesser,

Thank you for your reply.  
I belive that I have both the latest version of Docker ( 20.10.17) and Docker compose (2.6.0)

---

<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:** [August 19, 2022, 2:10pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/4 "2022-08-19T14:10:44Z")

</div>

Can you show the contents of your .env file?

```auto
# egrep ^[^#] .env
DOMAIN=mmtest.mydomain.com
TZ=UTC
RESTART_POLICY=unless-stopped
POSTGRES_IMAGE_TAG=13-alpine
POSTGRES_DATA_PATH=./volumes/db/var/lib/postgresql/data
POSTGRES_USER=mmuser
POSTGRES_PASSWORD=mmuser_password
POSTGRES_DB=mattermost
NGINX_IMAGE_TAG=alpine
NGINX_CONFIG_PATH=./nginx/conf.d
NGINX_DHPARAMS_FILE=./nginx/dhparams4096.pem
CERT_PATH=./volumes/web/cert/cert.pem
KEY_PATH=./volumes/web/cert/key-no-password.pem
HTTPS_PORT=443
HTTP_PORT=80
MATTERMOST_CONFIG_PATH=./volumes/app/mattermost/config
MATTERMOST_DATA_PATH=./volumes/app/mattermost/data
MATTERMOST_LOGS_PATH=./volumes/app/mattermost/logs
MATTERMOST_PLUGINS_PATH=./volumes/app/mattermost/plugins
MATTERMOST_CLIENT_PLUGINS_PATH=./volumes/app/mattermost/client/plugins
MATTERMOST_BLEVE_INDEXES_PATH=./volumes/app/mattermost/bleve-indexes
MM_BLEVESETTINGS_INDEXDIR=/mattermost/bleve-indexes
MATTERMOST_IMAGE=mattermost-team-edition
MATTERMOST_IMAGE_TAG=7.1.2
MATTERMOST_CONTAINER_READONLY=false
APP_PORT=8065
MM_SQLSETTINGS_DRIVERNAME=postgres
MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10
MM_SERVICESETTINGS_SITEURL=https://${DOMAIN}

```

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 2:16pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/5 "2022-08-19T14:16:07Z")

</div>

```auto

# Domain of service
DOMAIN=mattermost.mydomain.com

# Container settings
## Timezone inside the containers. The value needs to be in the form 'Europe/Berlin'.
## A list of these tz database names can be looked up at Wikipedia
## https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TZ=UTC
RESTART_POLICY=unless-stopped

# Postgres settings
## Documentation for this image and available settings can be found on hub.docker.com
## https://hub.docker.com/_/postgres
## Please keep in mind this will create a superuser and it's recommended to use a less privileged
## user to connect to the database.
## A guide on how to change the database user to a nonsuperuser can be found in docs/creation-of-nonsuperuser.md
POSTGRES_IMAGE_TAG=13-alpine
POSTGRES_DATA_PATH=./db/var/lib/postgresql/data

POSTGRES_USER=mmuser
POSTGRES_PASSWORD=mmuser_password
POSTGRES_DB=mattermost

# Nginx
## The nginx container will use a configuration found at the NGINX_MATTERMOST_CONFIG. The config aims
## to be secure and uses a catch-all server vhost which will work out-of-the-box. For additional settings
## or changes ones can edit it or provide another config. Important note: inside the container, nginx sources
## every config file inside */etc/nginx/conf.d* ending with a *.conf* file extension.

## Inside the container the uid and gid is 101. The folder owner can be set with
## `sudo chown -R 101:101 ./nginx` if needed.
NGINX_IMAGE_TAG=alpine

## The folder containing server blocks and any additional config to nginx.conf
NGINX_CONFIG_PATH=./nginx/conf.d
NGINX_DHPARAMS_FILE=./nginx/dhparams4096.pem

CERT_PATH=./web/cert/cert.pem
KEY_PATH=./web/cert/key-no-password.pem
#GITLAB_PKI_CHAIN_PATH=<path_to_your_gitlab_pki>/pki_chain.pem
#CERT_PATH=./certs/etc/letsencrypt/live/${DOMAIN}/fullchain.pem
#KEY_PATH=./certs/etc/letsencrypt/live/${DOMAIN}/privkey.pem

## Exposed ports to the host. Inside the container 80 and 443 will be used
HTTPS_PORT=443
HTTP_PORT=80

# Mattermost settings
## Inside the container the uid and gid is 2000. The folder owner can be set with
## `sudo chown -R 2000:2000 ./volumes/app/mattermost`.
MATTERMOST_CONFIG_PATH=./app/mattermost/config
MATTERMOST_DATA_PATH=./app/mattermost/data
MATTERMOST_LOGS_PATH=./app/mattermost/logs
MATTERMOST_PLUGINS_PATH=./app/mattermost/plugins
MATTERMOST_CLIENT_PLUGINS_PATH=./app/mattermost/client/plugins
MATTERMOST_BLEVE_INDEXES_PATH=./app/mattermost/bleve-indexes

## Bleve index (inside the container)
MM_BLEVESETTINGS_INDEXDIR=/mattermost/bleve-indexes

## This will be 'mattermost-enterprise-edition' or 'mattermost-team-edition' based on the version of Mattermost you're installing.
MATTERMOST_IMAGE=mattermost-enterprise-edition
MATTERMOST_IMAGE_TAG=7.1

## Make Mattermost container readonly. This interferes with the regeneration of root.html inside the container. Only use
## it if you know what you're doing.
## See https://github.com/mattermost/docker/issues/18
MATTERMOST_CONTAINER_READONLY=false

## The app port is only relevant for using Mattermost without the nginx container as reverse proxy. This is not meant
## to be used with the internal HTTP server exposed but rather in case one wants to host several services on one host
## or for using it behind another existing reverse proxy.
APP_PORT=8065

## Configuration settings for Mattermost. Documentation on the variables and the settings itself can be found at
## https://docs.mattermost.com/administration/config-settings.html
## Keep in mind that variables set here will take precedence over the same setting in config.json. This includes
## the system console as well and settings set with env variables will be greyed out.

## Below one can find necessary settings to spin up the Mattermost container
MM_SQLSETTINGS_DRIVERNAME=postgres
MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&>

## Example settings (any additional setting added here also needs to be introduced in the docker-compose.yml)
MM_SERVICESETTINGS_SITEURL=https://${DOMAIN}

```

---

<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:** [August 19, 2022, 2:22pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/6 "2022-08-19T14:22:57Z")

</div>

> [@JPzone282](#):
>
> `MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&>`

Is there really a caret `>` at the end of this line or does this indicate a linewrap?  
Besides that, the file looks good to me and to rule out an incompatibility with your docker-compose version, can you please manually replace the referenced variables in the `MM_SQLSETTINGS_DATASOURCE` and `MM_SERVICESETTINGS_SITEURL` configuration options with their respective values, just for testing purposes?

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 2:28pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/7 "2022-08-19T14:28:44Z")

</div>

Oh hang on its meant to be this

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

```

I have been following this [https://docs.mattermost.com/install/install-docker.html](https://docs.mattermost.com/install/install-docker.html)

---

<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:** [August 19, 2022, 2:33pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/8 "2022-08-19T14:33:45Z")

</div>

Yes, the documentation is correct and I don’t know exactly why it is not working, but it’s all about the `docker-compose` version. I’ve been through that many times already, so under certain circumstances which I still need to figure out yet, following the instructions will result in the error message you’re seeing and right now, you have three options:

- Find out what the problem is with the variable expansion in the .env files
- Upgrade to `docker compose` as a plugin (as opposed to `docker-compose`)
- Replace the variables with their values in the `.env` file

I’m trying to figure out what the exact circumstances are for the breakage, but didn’t have enough time as of yet.

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 2:41pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/9 "2022-08-19T14:41:04Z")

</div>

Okay, thank you anyway for looking into it. I’ll try and find a solution too.

---

<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:** [August 19, 2022, 3:04pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/10 "2022-08-19T15:04:40Z")

</div>

I did some further debugging now.  
Debian 11, freshly installed, `apt install docker docker-compose` will get you docker-compose version 1.25.0 and this version is too old.  
The first working version is [1.26.0](https://github.com/docker/compose/releases/tag/1.26.0), from this version upwards, it will immediately work, so if you want to give it a try, grab the latest docker-compose version from there and try again:

```auto
wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/v2.9.0/docker-compose-linux-x86_64
chmod 755 /usr/local/bin/docker-compose
/usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d

```

This should get you going, right?

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 3:29pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/11 "2022-08-19T15:29:29Z")

</div>

Aaha that has fixed it…

Now getting a database issue

2022-08-19 15:20:16.119 UTC [30] ERROR: relation “ir\_system” does not exist at character 20

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 4:22pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/12 "2022-08-19T16:22:38Z")

</div>

Looks like the database is restarting itself

---

<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:** [August 19, 2022, 6:13pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/13 "2022-08-19T18:13:18Z")

</div>

Maybe the restarting application server left your database broken; Can you please wipe the database volume again and start over new?  
Stop the containers, purge the database and start them again:

```auto
/usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml down
rm -r volumes/db/var
/usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d

```

Let me know if that worked.

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 6:18pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/14 "2022-08-19T18:18:32Z")

</div>

That worked it is not restarting itself.

Just getting a 502 error but i think it might be NGINX Proxy

---

<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:** [August 19, 2022, 6:46pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/15 "2022-08-19T18:46:36Z")

</div>

Are you running nginx as docker container or self hosted? If so, can you see anything in the nginx `error.log` that would help us? Usually, 502 just means that the connection from nginx to the backend is not working, maybe the port or hostname is wrong for the connection, hard to tell, but if you send me your `nginx.conf` as well as the output of `lsof -n -i` on your system (I assume all components are running on the same server?), I should be able to identify the problem.

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 6:56pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/16 "2022-08-19T18:56:33Z")

</div>

I do have a separate NGINX container for a subdomain should I edit the config in that? I also NGINX Proxy Manager.

Source = subdomain  
Destination = https:// docker-container-name:8065  
SSL certificate included

Should i have ran the with NGINX docker compose yaml file too?

These are the only possible errors I am getting in the mattermost container

```auto
{"timestamp":"2022-08-19 18:47:47.576 Z","level":"error","msg":"Failed to ping DB","caller":"sqlstore/store.go:238","error":"dial tcp 172.30.0.2:5432: connect: connection refused","retrying in seconds":10}

{"timestamp":"2022-08-19 18:47:59.935 Z","level":"error","msg":"License key from https://mattermost .com required to unlock enterprise features.","caller":"app/license.go:147","error":"resource: License id: "}

{"timestamp":"2022-08-19 18:47:59.976 Z","level":"error","msg":"License key from https://mattermost .com required to unlock enterprise features.","caller":"app/license.go:147","error":"resource: License id: "}

{"timestamp":"2022-08-19 18:48:03.744 Z","level":"debug","msg":"Skipped upstream: AWS Lambda: not configured.","caller":"app/plugin_api.go:934","plugin_id":"com.mattermost.apps","error":"AWS credentials are not set: not found"}

{"timestamp":"2022-08-19 18:48:03.745 Z","level":"debug","msg":"Skipped upstream: OpenFaaS: not configured.","caller":"app/plugin_api.go:934","plugin_id":"com.mattermost.apps","error":"OPENFAAS_URL environment variable must be defined: not found"}

{"timestamp":"2022-08-19 18:48:09.450 Z","level":"error","msg":"Mail server connection test failed","caller":"app/server.go:1216","error":"unable to connect: unable to connect to the SMTP server: dial tcp 127.0.0.1:10025: connect: connection refused"}

```

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 6:58pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/17 "2022-08-19T18:58:03Z")

</div>

Just sent a post but it has been hidden 😕

---

<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:** [August 19, 2022, 6:58pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/18 "2022-08-19T18:58:33Z")

</div>

Saw it and have released it - will take a look.

---

<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:** [August 19, 2022, 7:00pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/19 "2022-08-19T19:00:19Z")

</div>

> [@JPzone282](#):
>
> Destination = https:// docker-container-name:8065

This is not correct, it needs to be [http://docker-container-name:8065](http://docker-container-name:8065). The container itself does not have SSL on port 8065.

---

<div class="post-metadata">

**Author:** ![JPzone282](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@JPzone282](https://forum.mattermost.com/u/JPzone282)\
**Post date:** [August 19, 2022, 7:06pm UTC](https://forum.mattermost.com/t/setting-up-using-docker/13891/20 "2022-08-19T19:06:24Z")

</div>

Ahh okay. Getting this error

```auto
{"timestamp":"2022-08-19 19:02:39.730 Z","level":"debug","msg":"Skipped upstream: AWS Lambda: not configured.","caller":"app/plugin_api.go:934","plugin_id":"com.mattermost.apps","error":"AWS credentials are not set: not found"}
{"timestamp":"2022-08-19 19:02:39.731 Z","level":"debug","msg":"Skipped upstream: OpenFaaS: not configured.","caller":"app/plugin_api.go:934","plugin_id":"com.mattermost.apps","error":"OPENFAAS_URL environment variable must be defined: not found"}
{"timestamp":"2022-08-19 19:02:40.243 Z","level":"error","msg":"Mail server connection test failed","caller":"app/server.go:1216","error":"unable to connect: unable to connect to the SMTP server: dial tcp 127.0.0.1:10025: connect: connection refused"}

```

[Next page](https://forum.mattermost.com/t/setting-up-using-docker/13891.md?page=2)
