docker添加挂载目录:先在docker容器里创建目录/import
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目录
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。