How to Install Mattermost with Docker and Docker Compose
Mattermost is an open-source, self-hosted team communication platform that is often used as an alternative to Slack. This tutorial will guide you through setting up Mattermost using Docker and Docker Compose.
Prerequisites
- Docker installed on your system
- Docker Compose installed on your system
Create a Directory for Mattermost
Create a new directory for your Mattermost installation and navigate into it:
mkdir mattermost-docker
cd mattermost-docker
Create the docker-compose.yml
File
Create a docker-compose.yml
file in the directory with the following content:
version: '3.8'
services:
db:
image: postgres:13
container_name: mattermost-db
restart: unless-stopped
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: mmuser
POSTGRES_PASSWORD: mmuser_password
POSTGRES_DB: mattermost
app:
image: mattermost/mattermost-team-edition:latest
container_name: mattermost-app
restart: unless-stopped
ports:
- "8065:8065"
volumes:
- mattermost-data:/mattermost/data
environment:
MM_CONFIG: /mattermost/config/config.json
depends_on:
- db
volumes:
db-data:
mattermost-data:
Configure Environment Variables
In the docker-compose.yml
file, adjust the environment variables as needed:
- POSTGRES_USER: The username for the PostgreSQL database.
- POSTGRES_PASSWORD: The password for the PostgreSQL database.
- POSTGRES_DB: The name of the database for Mattermost.
Start the Docker Containers
Run the following command to start the Mattermost and PostgreSQL services:
docker-compose up -d
This command will pull the necessary Docker images and start the containers for Mattermost and PostgreSQL.
Access Mattermost
Once the containers are running, open your web browser and navigate to http://localhost:8065
. This will take you to the Mattermost setup screen, where you can configure your team and create an admin account.
Stopping the Containers
To stop the running containers, use the following command:
docker-compose down
This command will stop and remove the containers, but your data will remain intact in the volumes.
(Optional) Customizing Mattermost
If you want to customize your Mattermost instance, such as changing the configuration or adding plugins, you can do so by modifying the config.json
file located in the mattermost-data
volume.
Conclusion
Using Docker and Docker Compose to install Mattermost makes the setup process straightforward and manageable. This setup is suitable for both development and production environments, allowing you to easily deploy a secure and scalable team communication platform.