当前位置:   article > 正文

docker 通过修改config.v2.json的方式追加挂载点

config.v2.json

在创建容器时通过-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
  • 1
  • 2

在这里插入图片描述
于是准备先不使用-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
  • 1
  • 2
  • 3
  • 4

然后停止容器 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
  • 1
  • 2
  • 3

根据容器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
        }
    },

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/219450
推荐阅读
相关标签
  

闽ICP备14008679号