{"id":16540697,"url":"https://github.com/osixia/docker-mariadb","last_synced_at":"2025-10-28T14:31:41.428Z","repository":{"id":18691162,"uuid":"21900910","full_name":"osixia/docker-mariadb","owner":"osixia","description":"A docker image to run MariaDB with XtraBackup 🐳","archived":false,"fork":false,"pushed_at":"2020-10-17T18:46:52.000Z","size":2949,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"stable","last_synced_at":"2025-02-01T15:23:24.635Z","etag":null,"topics":["docker","docker-image","mariadb","xtrabackup"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/osixia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-16T13:08:28.000Z","updated_at":"2022-12-01T10:11:23.000Z","dependencies_parsed_at":"2022-09-25T01:33:18.613Z","dependency_job_id":null,"html_url":"https://github.com/osixia/docker-mariadb","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osixia%2Fdocker-mariadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osixia%2Fdocker-mariadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osixia%2Fdocker-mariadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osixia%2Fdocker-mariadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osixia","download_url":"https://codeload.github.com/osixia/docker-mariadb/tar.gz/refs/heads/stable","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238663138,"owners_count":19509738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","mariadb","xtrabackup"],"created_at":"2024-10-11T18:53:06.805Z","updated_at":"2025-10-28T14:31:38.306Z","avatar_url":"https://github.com/osixia.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# osixia/mariadb\n\n[![Docker Pulls](https://img.shields.io/docker/pulls/osixia/mariadb.svg)][hub]\n[![Docker Stars](https://img.shields.io/docker/stars/osixia/mariadb.svg)][hub]\n[![](https://images.microbadger.com/badges/image/osixia/mariadb.svg)](http://microbadger.com/images/osixia/mariadb \"Get your own image badge on microbadger.com\")\n\n[hub]: https://hub.docker.com/r/osixia/mariadb/\n\nLatest release: 10.4.10 - MariaDB 10.4.10 - [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/mariadb/) \n\n**A docker image to run MariaDB with perdiodic backups.**\n\u003e [MariaDB](https://mariadb.org/)\n\n\u003e [MariaDB Backup](https://mariadb.com/kb/en/library/mariadb-backup/)\n\n- [osixia/mariadb](#osixiamariadb)\n\t- [Quick start](#quick-start)\n\t- [Beginner Guide](#beginner-guide)\n\t\t- [Create new database](#create-new-database)\n\t\t\t- [Full example](#full-example)\n\t\t\t- [Data persistence](#data-persistence)\n\t\t- [Use an existing MariaDB database](#use-an-existing-mariadb-database)\n\t\t- [Administrate your mariadb server](#administrate-your-mariadb-server)\n\t\t- [Use a custom my.cnf](#use-a-custom-mycnf)\n\t\t- [SSL](#ssl)\n\t\t\t- [Use autogenerated certificate](#use-autogenerated-certificate)\n\t\t\t- [Use your own certificate](#use-your-own-certificate)\n\t\t\t- [Disable SSL](#disable-ssl)\n\t\t- [Fix docker mounted file problems](#fix-docker-mounted-file-problems)\n\t\t- [Debug](#debug)\n\t- [Environment Variables](#environment-variables)\n\t\t- [Set your own environment variables](#set-your-own-environment-variables)\n\t\t\t- [Use command line argument](#use-command-line-argument)\n\t\t\t- [Link environment file](#link-environment-file)\n\t\t\t- [Make your own image or extend this image](#make-your-own-image-or-extend-this-image)\n\t- [Advanced User Guide](#advanced-user-guide)\n\t\t- [Extend osixia/mariadb:10.4.10 image](#extend-osixiamariadb10410-image)\n\t\t- [Make your own MariaDB image](#make-your-own-mariadb-image)\n\t\t- [Tests](#tests)\n\t\t- [Kubernetes](#kubernetes)\n\t\t- [Under the hood: osixia/light-baseimage](#under-the-hood-osixialight-baseimage)\n\t- [Security](#security)\n\t- [Changelog](#changelog)\n\n## Quick start\nRun MariaDB docker image:\n\n\tdocker run --name my-mariadb-container --detach osixia/mariadb:10.4.10\n\nThis start a new container with a MariaDB server running inside.\n\nFirst we run a terminal on this container:\n\n\tdocker exec -it my-mariadb-container bash\n\nYou should now be in the container terminal,\nto properly use this terminal we need to fix the TERM environment variable :\n\n\texport TERM=xterm\n\nWe can now connect to the MariaDB server using mysql command line tool :\n\n\tmysql -u admin -padmin\n\n\n## Beginner Guide\n\n### Create new database\nThis is the default behavior when you run the image.\n\nIt will create an empty database, with a root and a debian-sys-maint user (required by MariaDB to run properly on debian).\nThe default root username (admin) and password (admin) can be changed at the docker command line, for example :\n\n\tdocker run --env MARIADB_ROOT_USER=JaxTeller --env MARIADB_ROOT_PASSWORD=SonsOfAnarchy --detach osixia/mariadb\n\nFor security reasons, by default the root user can only login to MariaDB from local networks.\nThis can also be changed at the docker command line.\n\nFor example if you want to allow MariaDB root login from docker default network and localhost :\n\n\tdocker run --env MARIADB_ROOT_ALLOWED_NETWORKS=\"#PYTHON2BASH:['172.17.%.%', 'localhost', '127.0.0.1', '::1']\" \\\n\t--detach osixia/mariadb\n\n\n#### Full example\nThis example will run a docker MariaDB container and execute an sql query from docker host:\n\n\tCONTAINER_ID=$(docker run --env MARIADB_ROOT_USER=JaxTeller \\\n\t\t--env MARIADB_ROOT_PASSWORD=SonsOfAnarchy \\\n\t\t--env MARIADB_ROOT_ALLOWED_NETWORKS=\"#PYTHON2BASH:['172.17.%.%', 'localhost', '127.0.0.1', '::1']\" \\\n\t\t--detach osixia/mariadb)\n\n\tCONTAINER_IP=$(docker inspect -f \"{{ .NetworkSettings.IPAddress }}\" $CONTAINER_ID)\n\n\tmysql -u JaxTeller -pSonsOfAnarchy -h $CONTAINER_IP -e \"select user,host from mysql.user\"\n\n\n#### Data persistence\n\nThe directory `/var/lib/mysql` (witch contains all MariaDB database files) has been declared as a volume, so your database files are saved outside the container in a data volume.\n\nFor more information about docker data volume, please refer to :\n\n\u003e [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/)\n\n### Use an existing MariaDB database\n\nThis can be achieved by mounting a host directory as volume.\nAssuming you have a MariaDB database on your docker host in the directory `/data/mariadb/CoolDb`\nsimply mount this directory as a volume to `/var/lib/mysql` :\n\n\tdocker run --volume /data/mariadb/CoolDb:/var/lib/mysql \\\n\t--env MARIADB_ROOT_USER=MyCoolDbRootUser \\\n\t--env MARIADB_ROOT_PASSWORD=MyCoolDbRootPassword \\\n\t--detach osixia/mariadb\n\nYou can also use data volume containers. Please refer to :\n\u003e [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/)\n\n### Administrate your mariadb server\nIf you are looking for a simple solution to administrate your MariaDB server you can take a look at our phpMyAdmin docker image:\n\u003e [osixia/phpmyadmin](https://github.com/osixia/docker-phpMyAdmin)\n\n\n### Use a custom my.cnf\n\nAdd your custom **my.cnf** in the directory **image/service/mariadb/assets** and rebuild the image ([see manual build](#manual-build)).\n\nOr you can set your custom config at run time, by mounting your **my.cnf** file to **/container/service/mariadb/assets/my.cnf**\n\n\tdocker run --volume /path/to/my.cnf:/container/service/mariadb/assets/my.cnf --detach osixia/mariadb\n\n### SSL\n\n#### Use autogenerated certificate\nBy default SSL is enable, a certificate is created with the container hostname (it can be set by docker run --hostname option eg: db.my-company.com).\n\n\tdocker run --hostname db.my-company.com --detach osixia/mariadb:10.4.10\n\n#### Use your own certificate\n\nYou can set your custom certificate at run time, by mounting a directory containing those files to **/container/service/mariadb/assets/certs** and adjust their name with the following environment variables:\n\n\tdocker run --volume /path/to/certificates:/container/service/mariadb/assets/certs \\\n\t--env MARIADB_SSL_CRT_FILENAME=my-cert.crt \\\n\t--env MARIADB_SSL_KEY_FILENAME=my-cert.key \\\n\t--env MARIADB_SSL_CA_CRT_FILENAME=the-ca.crt \\\n\t--detach osixia/mariadb:10.4.10\n\nOther solutions are available please refer to the [Advanced User Guide](#advanced-user-guide)\n\n#### Disable SSL\nAdd --env MARIADB_SSL=false to the run command :\n\n    docker run --env MARIADB_SSL=false --detach osixia/mariadb:10.4.10\n\n### Fix docker mounted file problems\n\nYou may have some problems with mounted files on some systems. The startup script try to make some file adjustment and fix files owner and permissions, this can result in multiple errors. See [Docker documentation](https://docs.docker.com/v1.4/userguide/dockervolumes/#mount-a-host-file-as-a-data-volume).\n\nTo fix that run the container with `--copy-service` argument :\n\n\t\tdocker run [your options] osixia/mariadb:10.4.10 --copy-service\n\n\n### Debug\n\nThe container default log level is **info**.\nAvailable levels are: `none`, `error`, `warning`, `info`, `debug` and `trace`.\n\nExample command to run the container in `debug` mode:\n\n\tdocker run --detach osixia/mariadb:10.4.10 --loglevel debug\n\nSee all command line options:\n\n\tdocker run osixia/mariadb:10.4.10 --help\n\n\n## Environment Variables\n\nEnvironment variables defaults are set in **image/environment/default.yaml**\n\nSee how to [set your own environment variables](#set-your-own-environment-variables)\n\nUsed when the container is started without an existing database:\n- **MARIADB_ROOT_USER**: The database root username. Defaults to `admin`\n- **MARIADB_ROOT_PASSWORD**: The database root password. Defaults to `admin`\n- **MARIADB_ROOT_ALLOWED_NETWORKS**: root login will only be allowed from those networks. Defaults to:\n\t```yaml\n\t- localhost\n  - 127.0.0.1\n  - ::1\n\t```\n\tIf you want to set this variable at docker run command add the tag `#PYTHON2BASH:` and convert the yaml in python:\n\n\t\tdocker run --env MARIADB_ROOT_ALLOWED_NETWORKS=\"#PYTHON2BASH:['localhost','127.0.0.1','::1']\" --detach osixia/mariadb:10.4.10\n\n\tTo convert yaml to python online: http://yaml-online-parser.appspot.com/\n\n- **MARIADB_DATABASES**: databases to be created on image startup. If user/password was supplied (see below) then  user will be granted superuser access (corresponding to GRANT ALL) to this database. You can also specify a user/password per database (see product database example) Defaults to ` ` (none).\n\n\tthis variable allows multiples values, for example :\n\t```yaml\n\t  - products:\n\t    - user: password\n\t    - user2: passw0rd\n\t  - posts\n\t  - tomatoes\n\t```\n\tIf you want to set this variable at docker run command add the tag `#PYTHON2BASH:` and convert the yaml in python:\n\n\t\tdocker run --env MARIADB_DATABASES=\"#PYTHON2BASH:[{'products': [{'user': 'password'}, {'user2': 'passw0rd'}]},'posts','tomatoes']\" --detach osixia/mariadb:10.4.10\n\n\tTo convert yaml to python online: http://yaml-online-parser.appspot.com/\n\n- **MARIADB_USERS**: create a new users with corresponding passwords. These users will be granted superuser permissions (see above) for the databases specified by the MARIADB_DATABASES variable. Defaults to ` ` (none).\n\n\tthis variable allows multiples values set has user: password for example :\n\t```yaml\n  - boby: mcD0nald\n  - billy: th3k1ng\n  - tomatoes: ketchup\n\t```\n\tIf you want to set this variable at docker run command add the tag `#PYTHON2BASH:` and convert the yaml in python:\n\n\t\tdocker run --env MARIADB_DATABASES=\"#PYTHON2BASH:[{'boby': 'mcD0nald'},{'billy': 'th3k1ng'},{'tomatoes': 'ketchup'}]\" --detach osixia/mariadb:10.4.10\n\n\tTo convert yaml to python online: http://yaml-online-parser.appspot.com/\n\nBackup :\n\n- **MARIADB_BACKUP_USER**: The database backup user username. Defaults to `backup`\n- **MARIADB_BACKUP_PASSWORD**: The database backup user password. Defaults to `backup`\n\n- **MARIADB_BACKUP_CRON_EXP**: Cron expression to schedule data backup. Defaults to `0 4 * * *`. Every days at 4am.\n\n- **MARIADB_BACKUP_TTL**: Backup TTL in days. Defaults to `15`.\n\nSSL :\n\n- **MARIADB_SSL**: Enable ssl. Defaults to `true`\n- **MARIADB_SSL_CIPHER_SUITE**: TLS cipher suite. Defaults to `TLSv1.2`\n- **MARIADB_SSL_CRT_FILENAME**: MariaDB ssl certificate filename. Defaults to `mariadb.crt`\n- **MARIADB_SSL_KEY_FILENAME**: MariaDB ssl certificate private key filename. Defaults to `mariadb.key`\n- **MARIADB_SSL_CA_CRT_FILENAME**: MariaDB ssl CA certificate filename. Defaults to `ca.crt`\n\n\tMore information at : https://mariadb.com/kb/en/mariadb/ssl-system-variables/\n\nOther environment variables:\n- **MARIADB_SSL_HELPER_PREFIX**: ssl-helper environment variables prefix. Defaults to `database`, ssl-helper first search config from DATABASE_SSL_HELPER_* variables, before SSL_HELPER_* variables.\n\n### Set your own environment variables\n\n#### Use command line argument\nEnvironment variables can be set by adding the --env argument in the command line, for example:\n\n\tdocker run --env MARIADB_ROOT_USER=\"JaxTeller\" --env MARIADB_ROOT_PASSWORD=\"Sons Of Anarchy\" --detach osixia/mariadb:10.4.10\n\n#### Link environment file\n\nFor example if your environment file is in :  /data/environment/my-env.yaml\n\n\tdocker run --volume /data/environment/my-env.yaml:/container/environment/01-custom/env.yaml \\\n\t--detach osixia/mariadb:10.4.10\n\nTake care to link your environment file to `/container/environment/XX-somedir` (with XX \u003c 99 so they will be processed before default environment files) and not  directly to `/container/environment` because this directory contains predefined baseimage environment files to fix container environment (INITRD, LANG, LANGUAGE and LC_CTYPE).\n\n#### Make your own image or extend this image\n\nThis is the best solution if you have a private registry. Please refer to the [Advanced User Guide](#advanced-user-guide) just below.\n\n## Advanced User Guide\n\n### Extend osixia/mariadb:10.4.10 image\n\nIf you need to add your custom TLS certificate, bootstrap config or environment files the easiest way is to extends this image.\n\nDockerfile example:\n\n    FROM osixia/mariadb:10.4.10\n    MAINTAINER Your Name \u003cyour@name.com\u003e\n\n    ADD ssl-certs /container/service/mariadb/assets/certs\n    ADD my.cnf /container/service/mariadb/assets/my.cnf\n    ADD environment /container/environment/01-custom\n\n\n### Make your own MariaDB image\n\n\nClone this project :\n\n\tgit clone https://github.com/osixia/docker-mariadb\n\tcd docker-mariadb\n\nAdapt Makefile, set your image NAME and VERSION, for example :\n\n\tNAME = osixia/mariadb\n\tVERSION = 10.2.6\n\n\tbecomes :\n\tNAME = billy-the-king/mariadb\n\tVERSION = 0.1.0\n\nAdd your custom certificate, environment files, my.cnf ...\n\nBuild your image :\n\n\tmake build\n\nRun your image :\n\n\tdocker run --detach billy-the-king/mariadb:0.1.0\n\n### Tests\n\nWe use **Bats** (Bash Automated Testing System) to test this image:\n\n\u003e [https://github.com/sstephenson/bats](https://github.com/sstephenson/bats)\n\nInstall Bats, and in this project directory run :\n\n\tmake test\n\n### Kubernetes\n\nKubernetes is an open source system for managing containerized applications across multiple hosts, providing basic mechanisms for deployment, maintenance, and scaling of applications.\n\nMore information:\n- http://kubernetes.io\n- https://github.com/kubernetes/kubernetes\n\nA kubernetes example is available in **example/kubernetes**\n\n### Under the hood: osixia/light-baseimage\n\nThis image is based on osixia/light-baseimage.\nMore info: https://github.com/osixia/docker-light-baseimage\n\n## Security\nIf you discover a security vulnerability within this docker image, please send an email to the Osixia! team at security@osixia.net. For minor vulnerabilities feel free to add an issue here on github.\n\nPlease include as many details as possible.\n\n## Changelog\n\nPlease refer to: [CHANGELOG.md](CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosixia%2Fdocker-mariadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosixia%2Fdocker-mariadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosixia%2Fdocker-mariadb/lists"}