How to run mattermost as a Docker container with MySQL DB

Method 1:

Create a file name dockercompose.yml and paste the below YAML code.

version: '3.3'
services:
    mattermost-team-edition:
        user: root
        container_name: mattermost
        hostname: mattermost
        volumes:
            - './plugins:/mattermost/client/plugins'
            - './config:/mattermost/config'
            - './data:/mattermost/data'
            - './logs:/mattermost/logs'
            - './plugins:/mattermost/plugins'
        environment:
            - MM_SQLSETTINGS_DRIVERNAME=mysql
            - MM_SQLSETTINGS_DATASOURCE="mattermost:dbpasswordf@tcp(192.168.1.111:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s'
        image: mattermost/mattermost-team-edition

Here change the 2nd environment = dbname:dbpassoord which you have created and in the IP address provide the IP of your database

Then modify the volume path based on your requirement

after changing all the requirements, run the below command to bring the stack up

docker-compose up -d

Method 2:

Docker run command to run the mattermost container

docker run -d --user root --name=mattermost -h mattermost \
  -v /mnt/disk_01/docker/volume/mattermost/client/plugins:/mattermost/client/plugins \
  -v /mnt/disk_01/docker/volume/mattermost/config:/mattermost/config \
  -v /mnt/disk_01/docker/volume/mattermost/data:/mattermost/data \
  -v /mnt/disk_01/docker/volume/mattermost/logs:/mattermost/logs \
  -v /mnt/disk_01/docker/volume/mattermost/plugins:/mattermost/plugins \
  -e MM_SQLSETTINGS_DRIVERNAME=mysql \
  -e MM_SQLSETTINGS_DATASOURCE='dbname:dbpassword@tcp(192.168.1.113:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s' \
  mattermost/mattermost-team-edition

modify the Env variables the same as the above docker-compose file

Leave a Reply

Your email address will not be published. Required fields are marked *