Skip to content

Commit

Permalink
MariaDB Server README
Browse files Browse the repository at this point in the history
Add MariaDB Server README.md with basic usage guide.
  • Loading branch information
alexandrevicenzi committed May 7, 2024
1 parent 8d36b40 commit b661b16
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bci_build/package/appcontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@
regex_in_build_description="%%mariadb_version%%",
package_name="mariadb",
parse_version="minor",
)
),
Replacement(
file_name="README.md",
regex_in_build_description="%%mariadb_version%%",
package_name="mariadb",
parse_version="minor",
),
],
pretty_name="MariaDB Server",
package_list=["mariadb", "mariadb-tools", "gawk", "timezone", "util-linux"],
Expand Down
64 changes: 64 additions & 0 deletions src/bci_build/package/mariadb/README.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# {{ image.pretty_name }} Container Image

MariaDB is an open-source, multi-threaded, relational database management system. It's a backward-compatible branch of the MySQL Community Server that provides a drop-in replacement for MySQL.

## Using the image

By default, the image launches MariaDB with the same configuration that comes with SUSE Linux Enterprise Server, with two exceptions: logging is sent to stdout, and binding to `localhost` is disabled.

The only environment variable required to start the container is the MariaDB root password.

```ShellSession
$ podman run -it --rm -p 3306:3306 -e MARIADB_ROOT_PASSWORD=my-password {{ image.pretty_reference }}
```

or:

```ShellSession
$ podman run -it --rm -p 3306:3306 -e MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 {{ image.pretty_reference }}
```

## Volumes

The database is stored in the directory `/var/lib/mysql`.

When using the MariaDB image, we recommend one of the following options:

* Use a named volume to manage the storage of your database data. This is the default option and it is easy to use. The downside is that the files may be hard to locate for tools and applications that run directly on the host system, i.e. outside containers.
* Create a data directory on the host system (outside the container) and mount the created directory to a directory accessible from inside the container. This stores the database files in a known location on the host system and makes it easy for tools and applications on the host system to access the files. If you choose this approach, make sure that the specified directory exists, and its permissions along with other security mechanisms on the host system are set up correctly.

To mount a host directory as a volume for your data run the following command:

```ShellSession
$ podman run -it --rm -v /my/own/datadir:/var/lib/mysql:Z -p 3306:3306 -e MARIADB_ROOT_PASSWORD=my-password {{ image.pretty_reference }}
```

The `-v /my/own/datadir:/var/lib/mysql:Z` part of the command mounts the `/my/own/datadir` directory from the underlying host system as `/var/lib/mysql` inside the container, where MariaDB will by default write its data files.

## Environment Variables

One of `MARIADB_RANDOM_ROOT_PASSWORD`, `MARIADB_ROOT_PASSWORD_HASH`, `MARIADB_ROOT_PASSWORD` or `MARIADB_ALLOW_EMPTY_ROOT_PASSWORD` (or equivalents, including `*_FILE`), is required.

All other environment variables are optional.

All environment variables are documented in the MariaDB's Knowledge Base [MariaDB Server Docker Official Image Environment Variables](https://mariadb.com/kb/en/mariadb-server-docker-official-image-environment-variables/).

## Health, liveness and readiness

There are no explicit health checks added to the container image. However, you can use the `healthcheck.sh` script to choose from a limited selection of tests to check for what you consider health, liveness, and readiness.

If there is no database initialized when the container starts, a default database is created. This means that incoming connections are not accepted until the initialization is completed. Use the `healthcheck.sh` script to check for container readiness.

To learn about `healthcheck.sh`, how to use it, and what tests are provided, refer to the MariaDB's Knowledge Base [Using Healthcheck.sh](https://mariadb.com/kb/en/using-healthcheck-sh/).

## Usage against an existing database

If you start a MariaDB container instance with a data directory that already contains a database (specifically, a MySQL subdirectory), no environment variables that control initialization are needed or examined, and no pre-existing databases are changed.

The only exception is the `MARIADB_AUTO_UPGRADE` environment variable. If it's set, it may run `mysql_upgrade` or `mariadb-upgrade`, potentially causing changes to the system tables.

## Backup and restore

Information on how to perform backup and restore can be found on the MariaDB Knowledge Base [Container Backup and Restoration](https://mariadb.com/kb/en/container-backup-and-restoration/).

{% include 'licensing_and_eula.j2' %}
1 change: 1 addition & 0 deletions src/bci_build/package/rmt-mariadb/README.md.j2

0 comments on commit b661b16

Please sign in to comment.