1. Create the MySQL container

We will use the latest MySQL image, here is the documentation MySQL Docker image

docker pull mysql:8.2.0

Create a mount directory

sudo mkdir -p /root/docker/mysql/conf.d

Create a cnf file for the mysql configuration

sudo vim /root/docker/mysql/conf.d/my-custom.cnf

With the contents:

[mysqld]
max_connections=250

Create the container

docker run \
--detach \
--name=mysql \
--env="MYSQL_ROOT_PASSWORD=secret" \
--env="MYSQL_DATABASE=simpleweb" \
--publish 6603:3306 \
--volume=/root/docker/mysql/conf.d:/etc/mysql/conf.d \
mysql

Connect to the MySQL client and test it is working

mysql -uroot -psecret -h127.0.0.1 -P6603 -e 'show global variables like "max_connections"';