1.拉取镜像文件
sudo docker pull mysql:5.7
2.创建实例并启动
docker run -p 3306:3306 --name mysql -v /mydata/mysql/log:/var/log/mysql -v /mydata/mysql/data:/var/lib/mysql -v /mydata/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
3.设置MySQL自启动
docker update --restart=always mysql
4.可能遇到异常问题
Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
5.解决方案
创建实例前在/mydata/mysql/conf/下创建conf.d 和 mysql.conf.d 目录