docker容器挂载主机目录

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>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值