MySQL Router 8.0  /  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 usergroup, 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:

shell> docker pull mysql/mysql-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 the list of tags for available versions on the mysql/mysql-router page in the Docker Hub.

Table 2.1 Variables

Variable Required/Optional
MYSQL_HOST Required
MYSQL_PORT Required
MYSQL_USER Required
MYSQL_PASSWORD Required
MYSQL_INNODB_CLUSTER_MEMBERS Optional

Running in a container requires a working InnoDB cluster. If supplied the run script waits for the given mysql host to be up, the InnoDB cluster to have MYSQL_INNODB_CLUSTER_MEMBERS members and then uses the given server for its bootstrap mode. See Section 3.1, “Bootstrapping MySQL Router”.

Example to run the image:

shell> docker run \
  -e MYSQL_HOST=localhost \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=mysql \
  -e MYSQL_PASSWORD=mysql \
  -e MYSQL_INNODB_CLUSTER_MEMBERS=3 \
  -ti mysql/mysql-router

Checking the status:

shell> docker ps

For addition details, such as the available environment variables, see Router's Docker Hub.