使用下面命令确认:
docker info
![图片alt](https://images.shenmazong.com/blog/9baee6aa-bc61-4cc6-a137-139d166b63d4.png ’‘图片title’’
docker pull centos/mysql-57-centos7
docker images
docker run -itd --name mysql-test -p 3307:3306 -e MYSQL_ROOT_PASSWORD=root centos/mysql-57-centos7:latest
docker ps
# 1、创建数据存储目录
mkdir -p /server/mysql/config
# 2、拷贝配置文件:有大坑,注意目录后面要有斜杠
docker cp mysql-test:/etc/my.cnf.d/ /server/mysql/config/
# 3、拷贝数据目录
docker cp mysql-test:/var/lib/mysql/data/ /server/mysql/
# 先停止容器
docker stop mysql5.7
# 再删除容器
docker rm mysql5.7
docker run -p 3306:3306 \
--name mysql5.7 \
-v /server/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d centos/mysql-57-centos7:latest