Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

#https://hub.docker.com/_/mariadb

#https://mariadb.com/kb/en/installing-and-using-mariadb-via-docker/

docker stop mariadb && docker rm mariadb
docker run -d --name="mariadb" \
-p 3306:3306 \
-e TZ="America/Whitehorse" \
-e MYSQL_ROOT_PASSWORD=PASSWORD \
-v "/opt/mariadb/conf/conf.d":"/etc/mysql/conf.d" \
-v "/opt/mariadb/backups":"/mnt/" \
--mount type=volume,dst=/var/run/mysqld,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=/var/run/mysqld \
mariadb:latest
#-v "/opt/mariadb/data":"/var/lib/mysql" \

Note:

Warning: skipping '!includedir /etc/mysql/conf.d/' directive as maximum includerecursion level was reached in file /etc/mysql/conf.d/mariadb.cnf at line 22
#You didn't link the conf.d correctly!

Bash Alias:

echo 'alias mdbcli="docker exec -it mariadb /bin/bash"' >> ~/.bashrc
source ~/.bashrc

Test Access:

MARIADBDOCKERIP="$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" mariadb)"
echo "$MARIADBDOCKERIP"
mysql -h "$MARIADBDOCKERIP" -u root -p

SystemD:

cat << 'EOL' >/lib/systemd/system/mariadb.service
[Unit]
Description=mariadb_Docker_Container
Requires=docker.service network-online.target

[Service]
Restart=on-abnormal
ExecStart=/usr/bin/docker start -a mariadb
ExecStop=/usr/bin/docker stop -t 2 mariadb

[Install]
WantedBy=multi-user.target
EOL
systemctl enable mariadb
systemctl restart mariadb
systemctl status mariadb
  • No labels