1、停止docker服务
systemctl stop docker.service(关键,修改之前必须停止docker服务)
首先,查看容器ID
docker ps -a
然后停止容器 docker stop XXXX
查找配置文件路径
find / -name config.v2.json
vim不容易编辑,可以在外面写好在mv过去
2、vim /var/lib/docker/containers/container-ID/config.v2.json
修改配置文件中的目录位置,然后保存退出
"MountPoints":{
"/etc/mysql":{
"Source":"/opt/model/mysql-5.7/conf",
"Destination":"/etc/mysql",
"RW":true,
"Name":"",
"Driver":"",
"Type":"bind",
"Propagation":"rprivate",
"Spec":{
"Type":"bind",
"Source":"/opt/model/mysql-5.7/conf",
"Target":"/etc/mysql"
},
"SkipMountpointCreation":false
},
"/var/lib/mysql":{
"Source":"/opt/model/mysql-5.7/data",
"Destination":"/var/lib/mysql",
"RW":true,
"Name":"",
"Driver":"",
"Type":"bind",
"Propagation":"rprivate",
"Spec":{
"Type":"bind",
"Source":"/opt/model/mysql-5.7/data",
"Target":"/var/lib/mysql"
},
"SkipMountpointCreation":false
},
"/var/log/mysql/error.log":{
"Source":"/opt/model/mysql-5.7/logs/error.log",
"Destination":"/var/log/mysql/error.log",
"RW":true,
"Name":"",
"Driver":"",
"Type":"bind",
"Propagation":"rprivate",
"Spec":{
"Type":"bind",
"Source":"/opt/model/mysql-5.7/logs/error.log",
"Target":"/var/log/mysql/error.log"
},
"SkipMountpointCreation":false
}
},
3、启动docker服务
systemctl start docker.service
4、启动docker容器
docker start <container-name/ID>