mysql - (servercontainers/mysql) (+ optional backup scheduler / restore) on alpine [x86 + arm]
4.1K
mysql/mariadb on alpine with backup scheduler and restore mechanism
This Dockerfile (available as servercontainers/mysql) gives you a MySQL/MariaDB SQL-Server on alpine. It is also possible to configure an auto mysqldump and restore mechanism.
For Configuration of the Server you use environment Variables.
It's based on the alpine Image
View in Docker Registry servercontainers/mysql
View in GitHub ServerContainers/mysql
You'll find all images tagged like a3.15.0-m10.6.4-r2 which means a<alpine version>-m<mysql/mariadb version>.
This way you can pin your installation/configuration to a certian version. or easily roll back if you experience any problems
(don't forget to open a issue in that case ;D).
The latest version will be updated/released after I managed to test a new pinned version in my production environment.
This way I can easily find and fix bugs without affecting any users. It will result in a way more stable container.
The daemon stores the database data beneath: /var/lib/mysql
Backup/Restore is disabled by default!
In default it stores it's dumps beneath: /var/mysql-backup
If you enable it the restore mechanism is automatically enabled too.
In default it loads the restorable dumps from /var/mysql-backup/to_restore/*.sql
If you enabled the backup via environment variable, you get mysql dumps for each database, and one big sql dump containing all databases.
You can also use this to easily restore a single database. Just copy the sql dump to the backup folders subfolder to_restore with the databasename as filename and .sql as suffix.
for example: to_restore/nextcloud.sql will be imported as database nextcloud.
The following example uses Docker Compose to start a example MySQL Server and a PhpMyAdmin Container
docker-compose up
After that just open https://localhost/ - ingore the self signed certificate warning and login with your mysql admin credentials admin / password.
The following command starts a non persistent mysql database which will be lost after the container is deleted. (Great for testing!)
docker run -d --name mysql \
-e 'ADMIN_USER=dbadmin' -e 'ADMIN_PASSWORD=adminpw' \
-e 'DB_NAME=testdb' -e 'DB_USER=testdbuser' -e 'DB_PASSWORD=usersecret' \
servercontainers/mysql
For the first start you'll need to provide the ADMIN_USER and ADMIN_PASSWORD variables
docker run -d --name mysql \
-e 'ADMIN_USER=dbadmin' -e 'ADMIN_PASSWORD=pa55worD!' \
-e 'BACKUP_ENABLED=enable' \
-p 3306:3306 \
-v /tmp/mysqldata:/var/lib/mysql \
-v /tmp/mysqlbackup:/var/mysql-backup \
servercontainers/mysql
you need to provide the admin credentials only if you start the container for the first time (so it can initialize a new Database) or if you use the internal mysqldump backup / restore mechanism
Now you can connect to the MySQL Server via the normal mysql-client cli:
mysql -u $ADMIN_USER -p -h $(docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID)
Content type
Image
Digest
sha256:48bb6a0d7…
Size
72.2 MB
Last updated
2 months ago
docker pull servercontainers/mysql