1.从docker hub上拉取mysql
docker pull mysql:5.6
2.配置mysql
docker run --name mysql -p 3306:3306 -v /mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
docker run --name mysql -p 3306:3306 -v /usr/local/mysql/conf/my.cnf:/etc/mysql/my.cnf
-v /usr/local/mysql/logs:/usr/local/mysql/logs
-v /usr/local/mysql/data:/usr/local/mysql/data
-e MYSQL_ROOT_PASSWORD=123456
-d mysql:5.6
-p 3306:3306:将容器的3306端口映射到主机的3306端口
-v /usr/local/mysql/conf/my.cnf:/etc/mysql/my.cnf:将主机当前目录下的my.cnf挂载到容器的/etc/mysql/my.cnf
-v /usr/local/mysql/logs:/usr/local/mysql/logs:将主机当前目录下的logs目录挂载到容器的/logs
-v /usr/local/mysql/data:/usr/local/mysql/data:将主机当前目录下的data目录挂载到容器的/usr/local/mysql/data
-e MYSQL_ROOT_PASSWORD=123456:初始化root用户的密码
3.查看mysql 内部ip
docker inspect mysql | grep Address