赞
踩
在创建容器时通过-v添加数据卷,但是一直提示路径下有文件无法初始化数据库(确实是已经清空路径下的文件了,但是不知到为什么会一直提示)
2021-08-23T15:28:22.431482Z 0 [ERROR] --initialize specified but the data directo ry has files in it. Aborting.
2021-08-23T15:28:22.431504Z 0 [ERROR] Aborting
于是准备先不使用-v参数挂在数据卷启动容器,然后通过修改config.v2.json的方式增加挂载点。
首先,查看容器ID
docker ps -a
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e12301bb7d3c mysql:5.7 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql5.7
9c0a2a9a92c4 nextcloud:latest "/entrypoint.sh apac…" 47 minutes ago Up 47 minutes 0.0.0.0:20080->80/tcp nextcloud
然后停止容器 docker stop XXXX
查找配置文件路径
find / -name config.v2.json
/share/CACHEDEV1_DATA/.qpkg/container-station/system-docker/containers/51b74ff705a5d41785657405a289713754a17749fe3c15f2ad002be948e3fd75/config.v2.json
/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/containers/9c0a2a9a92c40cf6ef1a684eb734717fe08136ed3acff5ea79e2b48fabf80c39/config.v2.json
/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/containers/e12301bb7d3cf286c7f9f1ef1d76c6d4ba288a587ca7df92243da596f9567434/config.v2.json
根据容器ID的前几位判断要修改的配置文件
文件内容很长,又没有格式化,于是借助工具查看。
如图MountPoints对应挂载点的配置项,其中从上到下依次对应配置文件挂载点、数据卷挂在点、日志挂载点
只需修改这几处即可
"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 } },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。