What you will set up
Mattermost is a chat for a company or a team, much like Slack: public and private channels, direct and group messages, threads, reactions, file sharing and search. It has apps for Windows, macOS, Linux, Android and iOS as well as the web, and webhooks and bots to connect it to other systems.
Mattermost is made by Mattermost, Inc., a company in Palo Alto, California, and developed in the open on GitHub. Team Edition is its free, open-source edition, the one this guide uses; the paid editions add features such as single sign-on and compliance exports. A server without a licence takes up to 250 active users, and warns from 200.
Here Mattermost runs as a Compose project under a user of its own called mattermost, with PostgreSQL for its data, behind Caddy from the Docker guide.
The app-specific results below come from the tested Podman guide on a Melonslab server with Debian 13:
- Mattermost 11.11.1 started with PostgreSQL 17. The first admin and a team were created from the command line before Caddy was set up, and a sign-up from outside without an invite was refused.
- A second user joined through the team's invite link. A message from one user appeared in the other's open browser within a fraction of a second, without a reload, over the websocket through Caddy.
- A 300 KB file and a 90 MB file were uploaded through Caddy and downloaded intact by the other user, and an image got a preview. A 110 MB file was refused with the size limit.
- Logins were logged with each visitor's real address, over IPv4 and IPv6, and a forged
X-Forwarded-Forheader was ignored. - Two-factor authentication worked with a time-based code, the kind an authenticator app shows.
- The interface and the emails were shown in both for one user and as the default for new users.
- With email pointed at a test mail server, over STARTTLS with a login, a password reset, an invite and a notification about a direct message all arrived. Without email, resets and email invites failed, as described in step 8.
- With the settings from step 3 and Calls off, a capture of the server's traffic showed no outside connections while Mattermost ran and was used, apart from one security check at the first start.
- An update from Mattermost 11.10.2 to 11.11.1 kept every message and file. Mattermost was restored from a backup into an empty database and empty volumes, and everything came back by itself after a reboot.
In the Podman test, the pod used about 230 MB of memory while in use, most of it Mattermost itself.
The Docker version below follows the tested rootless Docker base guide. The app-specific results above come from the tested Podman guide on a Melonslab server; they were not measured under Docker.
Before you start
You need:
- a server set up as in the Docker guide, with Caddy running;
- an A record and an AAAA record for
chat.example.compointing at your server.
The examples use chat.example.com for Mattermost, you@example.com for your own email address and Example for your team. Replace them throughout.
1. Create the user
As root:
useradd -m -s /bin/bash mattermost
loginctl enable-linger mattermost
uid=$(id -u mattermost)
Everything up to step 5 runs as mattermost.
2. Create the secrets
The passwords are generated with the Compose file in the next step and kept in a 0600 file under the app directory.
The 0600 file holds the database password for PostgreSQL and the address Mattermost connects to. sslmode=disable is fine here: the database is only reached inside the pod.
3. Define the Compose project
Create a Compose file in the app's directory. It uses the same images, ports, volumes, environment and restart policy as the Podman guide:
mkdir -p /home/mattermost/mattermost
cat > /home/mattermost/mattermost/compose.yaml <<'YAML'
services:
db:
image: docker.io/library/postgres:17-alpine
volumes:
- db:/var/lib/postgresql/data
environment:
POSTGRES_USER: mattermost
POSTGRES_DB: mattermost
env_file: mattermost.env
healthcheck:
test: ["CMD", "pg_isready", "-U", "mattermost"]
interval: 10s
restart: always
app:
image: docker.io/mattermost/mattermost-team-edition:11.11
ports:
- "127.0.0.1:8065:8065"
volumes:
- /home/mattermost/mattermost/config:/mattermost/config
- /home/mattermost/mattermost/data:/mattermost/data
environment:
MM_SERVICESETTINGS_SITEURL: https://chat.example.com
MM_SERVICESETTINGS_TRUSTEDPROXYIPHEADER: X-Forwarded-For
MM_SERVICESETTINGS_ENABLEMULTIFACTORAUTHENTICATION: "true"
MM_SQLSETTINGS_DRIVERNAME: postgres
MM_LOGSETTINGS_ENABLEDIAGNOSTICS: "false"
MM_LOGSETTINGS_ENABLESENTRY: "false"
MM_ANNOUNCEMENTSETTINGS_ADMINNOTICESENABLED: "false"
MM_ANNOUNCEMENTSETTINGS_USERNOTICESENABLED: "false"
MM_EMAILSETTINGS_PUSHNOTIFICATIONCONTENTS: generic
MM_LOCALIZATIONSETTINGS_DEFAULTSERVERLOCALE: sv
MM_LOCALIZATIONSETTINGS_DEFAULTCLIENTLOCALE: sv
env_file: mattermost.env
restart: always
volumes:
db:
YAML
umask 077
dbpw=$(openssl rand -hex 24)
printf 'POSTGRES_PASSWORD=%s\nMM_SQLSETTINGS_DATASOURCE=postgres://mattermost:%s@127.0.0.1:5432/mattermost?sslmode=disable&connect_timeout=10\n' "$dbpw" "$dbpw" > /home/mattermost/mattermost/mattermost.env
unset dbpw
chmod 600 /home/mattermost/mattermost/mattermost.env
chown -R mattermost:mattermost /home/mattermost/mattermost
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/mattermost/mattermost && docker compose up -d"
Use the weekly docker-update.service/docker-update.timer from the rootless Docker guide instead of Podman's auto-update timer. It runs docker compose pull and docker compose up -d in the app directory each Sunday. Set it up once for mattermost as shown there; it covers every Compose app in that user's home.
The first start downloads the images, about 1 GB on disk, and Mattermost takes half a minute to set up its database. It is ready when this prints {"status":"OK"} at the end:
curl -s http://127.0.0.1:8065/api/v4/system/ping
4. Create the admin and the team
On a new Mattermost, the first person to sign up becomes its system admin, so create your account before Mattermost can be reached from the internet. Mattermost's command-line tool, mmctl, can do that inside the container:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash <<'SH'
cd /home/mattermost/mattermost
pw=$(openssl rand -base64 18); echo "$pw"
docker compose exec -T app mmctl --local user create --email you@example.com --username anna --password "$pw" --system-admin --email-verified
docker compose exec -T app mmctl --local team create --name example --display-name Example
docker compose exec -T app mmctl --local team users add example anna
unset pw
SH
The first line makes a random password and prints it: keep it in your password manager. Then the account is created as system admin, a team is created, and you join it. --local talks to Mattermost through a socket inside the container, which the image switches on, so only someone who can run commands as mattermost can use it. You can change the password later under Profile > Security.
Then switch off Calls, Mattermost's voice and video calls:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash <<'SH'
cd /home/mattermost/mattermost
docker compose exec -T app mmctl --local plugin disable com.mattermost.calls
SH
Calls needs a UDP port of its own and a STUN server at Mattermost, which this guide does not set up. Without this line, users see call buttons that do not connect.
After the next restart, Calls is gone from mmctl --local plugin list as well: Mattermost unpacks its bundled plugins into the container at every start, and only the ones that are switched on. mmctl --local plugin enable com.mattermost.calls then answers Plugin is not installed. To switch Calls back on later, as mattermost:
echo '{"PluginSettings":{"PluginStates":{"com.mattermost.calls":{"Enable":true}}}}' | docker compose exec -T app mmctl --local config patch /dev/stdin
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/mattermost/mattermost && docker compose up -d --force-recreate app"
At the start, Mattermost installs Calls again from its image, and the plugin list shows it as enabled.
5. Put Caddy in front
Go back to root with exit, switch to runuser -u caddy -- /bin/bash, and add this block at the end of ~/Caddyfile:
chat.example.com {
reverse_proxy 127.0.0.1:8065
}
Restart Caddy with runuser -u caddy -- env HOME=/home/caddy XDG_RUNTIME_DIR=/run/user/$(id -u caddy) DOCKER_HOST=unix:///run/user/$(id -u caddy)/docker.sock PATH=/usr/bin:/bin bash -lc 'cd /home/caddy/caddy && docker compose restart caddy', and open https://chat.example.com. Choose View in Browser, and log in with anna and the password from step 4. Caddy passes on the websocket that Mattermost uses for live messages by itself, and has no size limit of its own for uploads.
6. Invite your team
Nobody can sign up without an invite: EnableOpenServer is off by default, and a sign-up without one gets "This server does not allow open signups."
To invite people, open the team menu, Example at the top left, and choose Invite people and Copy invite link. Send the link to your colleagues: it lets them create an account and join the team. It works without email, and anyone who has it can join, so share it only with the people you mean to invite.
A few settings worth knowing, under System Console, in the product menu at the top left:
- Site Configuration > Users and Teams > Max Users Per Team is 50. Raise it if your team is larger.
- Environment > File Storage > Maximum File Size is 100 MB. A larger file is refused with "exceeds the maximum allowed 104857600 bytes".
- User Management > Users lists every account, where you can deactivate those who leave.
Each user can turn on two-factor authentication under Profile > Security > Multi-factor Authentication, with an authenticator app.
7. Use Mattermost in Swedish
Mattermost comes translated into Swedish. Each user picks Svenska under Settings > Display > Language. Users will also want Clock Display set to 24-hour clock in the same place.
To make Swedish the default for new users and for the login page, these two entries are already in compose.yaml, so there is nothing to add. Restart:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/mattermost/mattermost && docker compose up -d --force-recreate app"
Accounts made before the change keep their language. Emails go out in each user's language.
8. Email
Mattermost sends email for password resets, invites by email, and notifications about direct messages and mentions to users who are away. This guide does not set up email, and without it:
- Forgot your password? fails with "Failed to send password reset email successfully.", so you reset passwords for your users yourself (below);
- invites by email fail with "Email invitations are disabled."; the invite link from step 6 still works;
- a bar at the top says "Preview Mode: Email notifications have not been configured."
Logins and chat work as usual. To set a new password for a user without email, as mattermost:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash <<'SH'
cd /home/mattermost/mattermost
docker compose exec -T app mmctl --local user change-password bo --password 'a-new-password'
SH
To send email, point Mattermost at your email provider's SMTP server. As mattermost, store the SMTP password as a secret:
The passwords are generated with the Compose file in the next step and kept in a 0600 file under the app directory.
Then add MM_EMAILSETTINGS_SMTPPASSWORD=<the-smtp-password> to mattermost.env, and these entries under app.environment in compose.yaml, with your own server, account and sender address:
MM_EMAILSETTINGS_SENDEMAILNOTIFICATIONS: "true"
MM_SERVICESETTINGS_ENABLEEMAILINVITATIONS: "true"
MM_EMAILSETTINGS_SMTPSERVER: mail.example.com
MM_EMAILSETTINGS_SMTPPORT: "587"
MM_EMAILSETTINGS_CONNECTIONSECURITY: STARTTLS
MM_EMAILSETTINGS_ENABLESMTPAUTH: "true"
MM_EMAILSETTINGS_SMTPUSERNAME: chat@example.com
MM_EMAILSETTINGS_FEEDBACKEMAIL: chat@example.com
MM_EMAILSETTINGS_FEEDBACKNAME: Chat
Restart as in step 7, and use System Console > Environment > SMTP > Test Connection to check it. Port 587 with STARTTLS upgrades the connection to TLS; for port 465, which uses TLS from the start, set the port to 465 and CONNECTIONSECURITY to TLS. We tested these settings against a test mail server on the same server, not through a real email provider.
9. Outside services
We captured the server's DNS lookups and outgoing connections from the first start on. On its first start, Mattermost looked up securityupdatecheck.mattermost.com (below), and Calls looked up stun.global.calls.mattermost.com until step 4 switched it off. After that, through restarts, a reboot and everyday use, there were none. Without the lines from step 3, Mattermost also contacted notices.mattermost.com and o94110.ingest.us.sentry.io at each start.
Some things still reach outside when they are used:
- When someone posts a link, the server fetches the page to show a preview. Site Configuration > Posts > Enable website link previews turns it off.
- Phone notifications from the Mattermost apps in the App Store and Google Play go through
push-test.mattermost.com, a push service Mattermost runs without guarantees for servers without a licence, and on through Apple and Google. WithPUSHNOTIFICATIONCONTENTS=generic, they carry the sender and channel name, not the message. We did not test the mobile apps. - Mattermost checks
securityupdatecheck.mattermost.comfor security fixes, according to its documentation, and emails the system admins when one concerns your version. We saw it once, at the first start. Environment > SMTP > Enable Security Alerts turns it off. - Marketplace in the product menu fetches the list of plugins from
api.integrations.mattermost.comwhen an admin opens it.
An outgoing webhook or slash command aimed at another app on this same server, such as n8n, needs one of the fixes in step 8 of the Docker guide. According to Mattermost's documentation, it refuses private addresses, such as the one an AddHost line gives, unless they are listed under Environment > Developer > Allow untrusted internal connections to, so the second fix is the simpler one here.
10. Back up
As mattermost:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash <<'SH'
cd /home/mattermost/mattermost
umask 077
mkdir -p ~/backup
docker compose exec -T db pg_dump -U mattermost mattermost > ~/backup/mattermost.sql
tar -cf ~/backup/mattermost-data.tar -C /home/mattermost/mattermost data
tar -cf ~/backup/mattermost-config.tar -C /home/mattermost/mattermost config
SH
That saves the messages, users and channels, the uploaded files, and the settings from the System Console. The dump runs while Mattermost keeps working. umask 077 makes new files readable by mattermost only; tar -cf keeps the file modes, which is why the lines use >. Copy ~/backup to another machine, for example with restic, and keep it private: it holds every message.
To restore, as mattermost, with the backup in ~/backup:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/mattermost/mattermost && docker compose stop app"
docker compose exec -T db dropdb -U mattermost --force mattermost
docker compose exec -T db createdb -U mattermost mattermost
docker compose exec -T db psql -q -U mattermost mattermost < ~/backup/mattermost.sql
rm -rf /home/mattermost/mattermost/data /home/mattermost/mattermost/config
tar -xf ~/backup/mattermost-data.tar -C /home/mattermost/mattermost
tar -xf ~/backup/mattermost-config.tar -C /home/mattermost/mattermost
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/mattermost/mattermost && docker compose up -d app"
On a new server, run steps 1 to 3 first, then restore. The database password is not in the backup, so new secrets are fine.
11. Update
Once a day, docker-auto-update.timer fetches new images for Mattermost 11.11 and PostgreSQL 17, and restarts the pod with them. To update right away, as mattermost:
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash <<'SH'
cd /home/mattermost/mattermost
docker compose pull && docker compose up -d
docker image prune -f
SH
Mattermost publishes a new release about every month, with a tag of its own: the version without its last number, such as 11.11 for 11.11.1. To move to a new release, take a backup, change the tag in compose.yaml, with NEW replaced by the new tag, and restart:
sed -i 's/team-edition:11.11/team-edition:NEW/' /home/mattermost/mattermost/compose.yaml
uid=$(id -u mattermost)
runuser -u mattermost -- env HOME=/home/mattermost XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/mattermost/mattermost && docker compose up -d --force-recreate app"
docker compose down && docker compose up -d
Mattermost updates its database by itself when it starts. Read the release notes before a new major version, such as 12. Recreating the project replaces the old containers. The old image stays on disk until you prune it. We moved from 11.10 to 11.11 this way, and the team and data were kept.
Troubleshooting
Every login under Profile > Security > View Access History has the server's own address. MM_SERVICESETTINGS_TRUSTEDPROXYIPHEADER is missing from compose.yaml. Add it, then daemon-reload and restart mattermost-app.
A setting is greyed out in the System Console. It is set by an MM_ entry in compose.yaml. Change it there and restart.
The log says "this plugin requires a professional license or higher" for Playbooks. Playbooks comes with Mattermost but needs a paid licence. The message is harmless.