docker network create my-custom-net 

Then, when you are creating and starting the server and the client containers, use the --network  option to put them on network you created. For example: 

docker run --name=mysql1 --network= my-custom-net  -d mysql/mysql-server 

docker run --name=myapp1 --network= my-custom-net  -d myapp 

The myapp1  container can then connect to the mysql1  container with the mysql1  hostname and vice versa, as Docker automatically sets up a DNS for the given container names. In the following example, we run the mysql  client from inside the myapp1  container to connect to host mysql1  in its own container: 

docker exec -it myapp1 mysql --host=mysql1 --user=myuser --password 

For other networking techniques for containers, see the Docker container networking section in the Docker Documentation. 

## Server Error Log 

When the MySQL Server is first started with your server container, a server error log is NOT generated if either of the following conditions is true: 

•A server configuration file from the host has been mounted, but the file does not contain the system variable log_error  (see Persisting Data and Configuration Changes on bind-mounting a server configuration file). 

•A server configuration file from the host has not been mounted, but the Docker environment variable MYSQL_LOG_CONSOLE  is true  (which is the variable’s default state for MySQL 8.0 server containers). The MySQL Server’s error log is then redirected to stderr , so that the error log goes into the Docker container’s log and is viewable using the docker logs mysqld-container  command. 

To make MySQL Server generate an error log when either of the two conditions is true, use the --log- error  option to configure the server to generate the error log at a specific location inside the container. To persist the error log, mount a host file at the location of the error log inside the container as explained in Persisting Data and Configuration Changes. However, you must make sure your MySQL Server inside its container has write access to the mounted host file. 

## Using MySQL Enterprise Backup with Docker 

MySQL Enterprise Backup is a commercially-licensed backup utility for MySQL Server, available with MySQL Enterprise Edition. MySQL Enterprise Backup is included in the Docker installation of MySQL Enterprise Edition. 

In the following example, we assume that you already have a MySQL Server running in a Docker container (see Section 2.5.6.1, “Basic Steps for MySQL Server Deployment with Docker”  on how to start a MySQL Server instance with Docker). For MySQL Enterprise Backup to back up the MySQL Server, it must have access to the server’s data directory. This can be achieved by, for example, bind-mounting a host directory on the data directory of the MySQL Server when you start the server: 

docker run --name=mysqlserver \ --mount type=bind,src= /path-on-host-machine/datadir/ ,dst=/var/lib/mysql \ -d mysql/enterprise-server:8.0 

With this command, the MySQL Server is started with a Docker image of the MySQL Enterprise Edition, and the host directory /path-on-host-machine/datadir/  has been mounted onto the server’s data directory ( /var/lib/mysql ) inside the server container. We also assume that, after the server has been started, the required privileges have also been set up for MySQL Enterprise Backup to access the server (see Grant MySQL Privileges to Backup Administrator for details). Use the following steps then to backup and restore a MySQL Server instance. 

