mkdir /data/mysql/data
mkdir /data/mysql/conf
mkdir /data/mysql/logs
chmod 777 /data/mysql/data
chmod 777 /data/mysql/conf
chmod 777 /data/mysql/logs
touch /data/mysql/docmysql.sh
chmod 777 /data/mysql/docmysql.sh
默认docker 安装了Mysql5.7
vim /data/mysql/docmysql.sh
docker rm mysql-all
DB_HOME=/data/mysql
DB_CONF_PATH=$DB_HOME/conf:/etc/mysql/conf.d
DB_LOG_PATH=$DB_HOME/logs:/var/log/mysql
DB_DATA_PATH=$DB_HOME/data:/var/lib/mysql
docker run -p 3306:3306 --name=mysql-all -v $DB_CONF_PATH -v $DB_LOG_PATH -v DB_DATA_PATH -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
如果访问不了mysql可能是docker默认网桥不行
创建网桥:
https://blog.csdn.net/wanhuaqiu/article/details/81052538