MySQL Router 9.1  /  Installing MySQL Router  /  Installing MySQL Router with Docker

2.2 Installing MySQL Router with Docker

The Docker deployment framework supports easy installation and configuration of MySQL Router. This section explains how to use a MySQL Router Docker image.

You need to have Docker installed on your system before you can use a MySQL Router Docker image. See Install Docker for instructions.

Important

You need to either run docker commands with sudo, or create a docker user group, and then add to it any users who want to run docker commands. See details here. Because Docker containers are always run with root privileges, you should understand the Docker daemon attack surface and properly mitigate the related risks.

Basic Steps for MySQL Router Deployment with Docker

Warning

The MySQL Docker images maintained by the MySQL team are built specifically for Linux platforms. Other platforms are not supported, and users using these MySQL Docker images on them are doing so at their own risk.

Downloading a MySQL Router Docker Image

Downloading the server image in a separate step is not strictly necessary; however, performing this step before you create your Docker container ensures your local image is up to date. To download the MySQL Community Edition image, run this command:

$> docker pull container-registry.oracle.com/mysql/community-router:tag

The tag is the label for the image version you want to pull (for example, 8.0). If :tag is omitted, the latest label is used, and the image for the latest GA version of MySQL Community Router is downloaded. Refer to Oracle Container Registry and navigate to the MySQL Router image in the MySQL repository for a complete list of tags for available versions.

Table 2.1 Variables

Variable Description
MYSQL_HOST Required. MySQL host to connect to.
MYSQL_PORT Required. MySQL server listening port.
MYSQL_USER Required. MySQL user to connect with.
MYSQL_PASSWORD Required. String. MySQL user's password.
MYSQL_INNODB_CLUSTER_MEMBERS Optional. Integer. Wait for this number of cluster instances to be online.
MYSQL_CREATE_ROUTER_USER Optional. Boolean. Whether to create a new account for MySQL Router to use when running. Default value is enabled (1). Set to 0 (zero) to disable.
MYSQL_ROUTER_BOOTSTRAP_EXTRA_OPTIONS Optional. Comma-separated list of additional command line options to apply during bootstrapping.

Running in a container requires a working InnoDB cluster. If supplied, the run script waits for the given mysql host to start, the InnoDB cluster to have the MYSQL_INNODB_CLUSTER_MEMBERS-defined number of members, and then uses the supplied host for bootstrapping. See Section 3.1, “Bootstrapping MySQL Router”.

For example:

$> docker run \
  -e MYSQL_HOST=localhost \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=mysql \
  -e MYSQL_PASSWORD=mysql \
  -e MYSQL_INNODB_CLUSTER_MEMBERS=3 \
  -e MYSQL_ROUTER_BOOTSTRAP_EXTRA_OPTIONS="--conf-use-socket --conf-use-gr-notification" \
  -ti container-registry.oracle.com/mysql/community-router

To use a specific version of MySQL Router, add a tag to the -ti value. For example: -ti container-registry.oracle.com/mysql/community-router:9.0.0 for MySQL Router 9.0.0. To use the latest version, do not add a tag.

Checking the status:

$> docker ps

For additional details, see Oracle Container Registry and navigate to the MySQL Router image in the MySQL repository.