set enviroment variable
export MARIADB=/srv/mariadb
and add previous line to .bashrc file
custom mariadb version 10.4.7
docker run --name CONTAINER_NAME --restart=always -v VOLUME_NAME:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=1 -d -p 3306:3306 ledangtuanbk/mariadb:10.4.7
docker exec -t CONTAINER_NAME mysqldump -u root -p MYSQL_ROOT_PASSWORD DATABASE_NAME > /mnt/backup_date +%d-%m-%Y"_"%H_%M_%S
.sql
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root -p MYSQL_ROOT_PASSWORD DATABASE_NAME
version: '3.3'
services:
mariadb:
container_name: mariadb
restart: always
volumes:
- '$MARIADB_HOME/data:/var/lib/mysql'
# - '$MARIADB_HOME/mysql:/etc/mysql'
environment:
- MYSQL_ROOT_PASSWORD=1
ports:
- '3306:3306'
image: 'ledangtuanbk/mariadb:10.4.7'
MARIADB_HOME=/srv/mariadb