Deploy MariaDB 10.5.5 in Docker Swarm behind Traefik Proxy

Опубликовано: 06 Август 2026
на канале: TUNEIT
3,633
28

Learn how to deploy MariaDB 10.5.5 to Docker Swarm Cluster behind Traefik proxy to act as a database server for all the micro-services; which has mounted replicated glusterfs volume for data high availability.

#Mariadb
#Mariadbdocker
#MariadbTraefik
#Database

Full blog post here: https://rb.gy/lwqbgs

Useful referral links
=========================================
Digital ocean - https://m.do.co/c/4fc5bb284d41

Rasberry Pi - https://uk.pi-supply.com/?ref=cjv78_u...

Create beautiful social media graphics - https://www.canva.com/join/wqj-rnt-rtx

==Please setup Docker Swarm Cluster; setup Glusterfs Replicated Volume in it and deploy Traefik before deploying MariaDB. Please find below videos for the same==

Setup Docker Swarm in Azure on Ubuntu 20.04
=========================================
   • Setup Docker Swarm Cluster on Ubuntu 20.04...  

Full blog post for docker swarm cluster - https://rb.gy/lbcj6e

Setup Glusterfs Replicated volume in Docker Swarm
=========================================
   • Install GlusterFS as Replicated Storage Vo...  

Full blog post for Glusterfs Replicated Volume - https://rb.gy/lbcj6e

Deploy Traefik v2.0 in Docker Swarm as a reverse proxy
=========================================
   • Deploy Traefik v2.0 - Cloud Native Edge Ro...  

Full blog post for deploying Traefik in Docker Swarm - https://rb.gy/ayr4f9

/=========================================/
Please find the full list of commands below.
/=========================================/

Create docker secrets to use in MariaDB Container
=========================================
echo "{test@123}" | docker secret create mysql_root_password -
echo "{test@123}" | docker secret create mysql_db_password -

Create local glusterfs folder to map db container volumes
=========================================
cd /mnt
sudo mkdir -p mariadb

Give permissions for glusterfs folder
=========================================
sudo chown -R www-data:www-data folderpath

MariaDB Configuration - docker compose
=========================================
version: "3.7"

services:
maindb:
image: mariadb
volumes:
/mnt/mariadb:/var/lib/mysql
secrets:
mysql_db_password
mysql_root_password
environment:
MYSQL_USER=rajasekhar
MYSQL_DATABASE=main
MYSQL_PASSWORD_FILE=/run/secrets/mysql_db_password
MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
command: ["mysqld", "--wait_timeout=28800", "--interactive_timeout=28800", "--max_allowed_packet=256M"]
networks:
proxy
deploy:
placement:
constraints: [node.role == manager]
replicas: 1
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
secrets:
mysql_db_password:
external: true
mysql_root_password:
external: true
volumes:
mariadb:
driver: "local"
networks:
proxy:
external: true

Deploy MariaDB using docker stack deploy
=========================================
sudo docker stack deploy --compose-file maria.yml maindb

Check MariaDb stack status and service logs
=========================================
docker stack ps maindb
docker service logs maindb_maindb

Log into MariaDB docker container
=========================================
docker exec -it [my_image_id or name] bash

Log into MariaDB server
=========================================
mysql -P 3306 --protocol=tcp -u root -p

Commands to manage MariaDB container
=========================================
show databases;
create database test;
drop database test;

/=========================================/
Remember to leave a comment or like on this video and subscribe if you want to see more!
/=========================================/