189 8069 5689

docker给已经启动容器添加挂载目录

docker添加挂载目录:先在docker容器里创建目录/import

创新互联主营济阳网站建设的网络公司,主营网站建设方案,APP应用开发,济阳h5成都小程序开发搭建,济阳网站营销推广欢迎济阳等地区企业咨询

1.关闭docker:/etc/init.d/docker stop
2.sudo su切换到root身份,cd /var/lib/docker/containers/容器id/,进入对应容器目录
3.vi hostconfig.json,修改如下,将容器目录/import绑定到主机/data目录:

"Binds": ["/data:/import"],

4.vi config.v2.json,修改如下,添加MountPoints:

"MountPoints": {

"/import": {
            "Source": "/data",
            "Destination": "/import",
            "RW": true,
            "Name": "",
            "Driver": "",
            "Type": "bind",
            "Propagation": "rprivate",
            "Spec": {
                "Type": "bind",
                "Source": "/data",
                "Target": "/import"
            },
            "SkipMountpointCreation": false
        }
},  

5.启动docker:/etc/init.d/docker start

最后docker ecec -it 容器id /bin/bash进入ls -l /就可以看见import目录

本文题目:docker给已经启动容器添加挂载目录
网站地址:http://cdxtjz.com/article/jpsphp.html

其他资讯