|
|
@@ -10,12 +10,12 @@ The intent is also to maintain high compatibility with MySQL, ensuring a "drop-i
|
|
|
|
|
|
# How to use this image
|
|
|
|
|
|
-## Start a `%%REPO%%` server instance
|
|
|
+## Start a `%%IMAGE%%` server instance
|
|
|
|
|
|
Starting a MariaDB instance is simple:
|
|
|
|
|
|
```console
|
|
|
-$ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%REPO%%:tag
|
|
|
+$ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE%%:tag
|
|
|
```
|
|
|
|
|
|
... where `some-%%REPO%%` is the name you want to assign to your container, `my-secret-pw` is the password to be set for the MySQL root user and `tag` is the tag specifying the MySQL version you want. See the list above for relevant tags.
|
|
|
@@ -32,18 +32,18 @@ $ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses
|
|
|
|
|
|
## Connect to MariaDB from the MySQL command line client
|
|
|
|
|
|
-The following command starts another %%REPO%% container instance and runs the `mysql` command line client against your original %%REPO%% container, allowing you to execute SQL statements against your database instance:
|
|
|
+The following command starts another `%%IMAGE%%` container instance and runs the `mysql` command line client against your original `%%IMAGE%%` container, allowing you to execute SQL statements against your database instance:
|
|
|
|
|
|
```console
|
|
|
-$ docker run -it --link some-%%REPO%%:mysql --rm %%REPO%% sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
|
|
|
+$ docker run -it --link some-%%REPO%%:mysql --rm %%IMAGE%% sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
|
|
|
```
|
|
|
|
|
|
-... where `some-%%REPO%%` is the name of your original %%REPO%% container.
|
|
|
+... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container.
|
|
|
|
|
|
This image can also be used as a client for non-Docker or remote MariaDB instances:
|
|
|
|
|
|
```console
|
|
|
-$ docker run -it --rm %%REPO%% mysql -hsome.mysql.host -usome-mysql-user -p
|
|
|
+$ docker run -it --rm %%IMAGE%% mysql -hsome.mysql.host -usome-mysql-user -p
|
|
|
```
|
|
|
|
|
|
More information about the MySQL command line client can be found in the [MySQL documentation](http://dev.mysql.com/doc/en/mysql.html)
|
|
|
@@ -54,7 +54,7 @@ Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml
|
|
|
|
|
|
## Container shell access and viewing MySQL logs
|
|
|
|
|
|
-The `docker exec` command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your `%%REPO%%` container:
|
|
|
+The `docker exec` command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your `%%IMAGE%%` container:
|
|
|
|
|
|
```console
|
|
|
$ docker exec -it some-%%REPO%% bash
|
|
|
@@ -68,12 +68,12 @@ $ docker logs some-%%REPO%%
|
|
|
|
|
|
## Using a custom MySQL configuration file
|
|
|
|
|
|
-The MariaDB startup configuration is specified in the file `/etc/mysql/my.cnf`, and that file in turn includes any files found in the `/etc/mysql/conf.d` directory that end with `.cnf`. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as `/etc/mysql/conf.d` inside the `%%REPO%%` container.
|
|
|
+The MariaDB startup configuration is specified in the file `/etc/mysql/my.cnf`, and that file in turn includes any files found in the `/etc/mysql/conf.d` directory that end with `.cnf`. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as `/etc/mysql/conf.d` inside the `%%IMAGE%%` container.
|
|
|
|
|
|
-If `/my/custom/config-file.cnf` is the path and name of your custom configuration file, you can start your `%%REPO%%` container like this (note that only the directory path of the custom config file is used in this command):
|
|
|
+If `/my/custom/config-file.cnf` is the path and name of your custom configuration file, you can start your `%%IMAGE%%` container like this (note that only the directory path of the custom config file is used in this command):
|
|
|
|
|
|
```console
|
|
|
-$ docker run --name some-%%REPO%% -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%REPO%%:tag
|
|
|
+$ docker run --name some-%%REPO%% -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE%%:tag
|
|
|
```
|
|
|
|
|
|
This will start a new container `some-%%REPO%%` where the MariaDB instance uses the combined startup settings from `/etc/mysql/my.cnf` and `/etc/mysql/conf.d/config-file.cnf`, with settings from the latter taking precedence.
|
|
|
@@ -89,18 +89,18 @@ $ chcon -Rt svirt_sandbox_file_t /my/custom
|
|
|
Many configuration options can be passed as flags to `mysqld`. This will give you the flexibility to customize the container without needing a `cnf` file. For example, if you want to change the default encoding and collation for all tables to use UTF-8 (`utf8mb4`) just run the following:
|
|
|
|
|
|
```console
|
|
|
-$ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%REPO%%:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
|
|
+$ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE%%:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
|
|
```
|
|
|
|
|
|
If you would like to see a complete list of available options, just run:
|
|
|
|
|
|
```console
|
|
|
-$ docker run -it --rm %%REPO%%:tag --verbose --help
|
|
|
+$ docker run -it --rm %%IMAGE%%:tag --verbose --help
|
|
|
```
|
|
|
|
|
|
## Environment Variables
|
|
|
|
|
|
-When you start the `%%REPO%%` image, you can adjust the configuration of the MariaDB instance by passing one or more environment variables on the `docker run` command line. Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.
|
|
|
+When you start the `%%IMAGE%%` image, you can adjust the configuration of the MariaDB instance by passing one or more environment variables on the `docker run` command line. Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.
|
|
|
|
|
|
### `MYSQL_ROOT_PASSWORD`
|
|
|
|
|
|
@@ -129,20 +129,20 @@ This is an optional variable. Set to `yes` to generate a random initial password
|
|
|
As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in `/run/secrets/<secret_name>` files. For example:
|
|
|
|
|
|
```console
|
|
|
-$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root -d %%REPO%%:tag
|
|
|
+$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root -d %%IMAGE%%:tag
|
|
|
```
|
|
|
|
|
|
Currently, this is only supported for `MYSQL_ROOT_PASSWORD`, `MYSQL_ROOT_HOST`, `MYSQL_DATABASE`, `MYSQL_USER`, and `MYSQL_PASSWORD`.
|
|
|
|
|
|
# Initializing a fresh instance
|
|
|
|
|
|
-When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions `.sh`, `.sql` and `.sql.gz` that are found in `/docker-entrypoint-initdb.d`. Files will be executed in alphabetical order. You can easily populate your %%REPO%% services by [mounting a SQL dump into that directory](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume) and provide [custom images](https://docs.docker.com/reference/builder/) with contributed data. SQL files will be imported by default to the database specified by the `MYSQL_DATABASE` variable.
|
|
|
+When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions `.sh`, `.sql` and `.sql.gz` that are found in `/docker-entrypoint-initdb.d`. Files will be executed in alphabetical order. You can easily populate your `%%IMAGE%%` services by [mounting a SQL dump into that directory](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume) and provide [custom images](https://docs.docker.com/reference/builder/) with contributed data. SQL files will be imported by default to the database specified by the `MYSQL_DATABASE` variable.
|
|
|
|
|
|
# Caveats
|
|
|
|
|
|
## Where to Store Data
|
|
|
|
|
|
-Important note: There are several ways to store data used by applications that run in Docker containers. We encourage users of the `%%REPO%%` images to familiarize themselves with the options available, including:
|
|
|
+Important note: There are several ways to store data used by applications that run in Docker containers. We encourage users of the `%%IMAGE%%` images to familiarize themselves with the options available, including:
|
|
|
|
|
|
- Let Docker manage the storage of your database data [by writing the database files to disk on the host system using its own internal volume management](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume). This is the default and is easy and fairly transparent to the user. 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 this to a directory visible from inside the container](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume). This places 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. The downside is that the user needs to make sure that the directory exists, and that e.g. directory permissions and other security mechanisms on the host system are set up correctly.
|
|
|
@@ -150,10 +150,10 @@ Important note: There are several ways to store data used by applications that r
|
|
|
The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blogs and forum postings that discuss and give advice in this area. We will simply show the basic procedure here for the latter option above:
|
|
|
|
|
|
1. Create a data directory on a suitable volume on your host system, e.g. `/my/own/datadir`.
|
|
|
-2. Start your `%%REPO%%` container like this:
|
|
|
+2. Start your `%%IMAGE%%` container like this:
|
|
|
|
|
|
```console
|
|
|
- $ docker run --name some-%%REPO%% -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%REPO%%:tag
|
|
|
+ $ docker run --name some-%%REPO%% -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE%%:tag
|
|
|
```
|
|
|
|
|
|
The `-v /my/own/datadir:/var/lib/mysql` part of the command mounts the `/my/own/datadir` directory from the underlying host system as `/var/lib/mysql` inside the container, where MySQL by default will write its data files.
|
|
|
@@ -170,7 +170,7 @@ If there is no database initialized when the container starts, then a default da
|
|
|
|
|
|
## Usage against an existing database
|
|
|
|
|
|
-If you start your `%%REPO%%` container instance with a data directory that already contains a database (specifically, a `mysql` subdirectory), the `$MYSQL_ROOT_PASSWORD` variable should be omitted from the run command line; it will in any case be ignored, and the pre-existing database will not be changed in any way.
|
|
|
+If you start your `%%IMAGE%%` container instance with a data directory that already contains a database (specifically, a `mysql` subdirectory), the `$MYSQL_ROOT_PASSWORD` variable should be omitted from the run command line; it will in any case be ignored, and the pre-existing database will not be changed in any way.
|
|
|
|
|
|
## Creating database dumps
|
|
|
|