docker添加掛載目錄:先在docker容器里創(chuàng)建目錄/import
創(chuàng)新互聯(lián)主營濟(jì)陽網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,APP應(yīng)用開發(fā),濟(jì)陽h5成都小程序開發(fā)搭建,濟(jì)陽網(wǎng)站營銷推廣歡迎濟(jì)陽等地區(qū)企業(yè)咨詢
1.關(guān)閉docker:/etc/init.d/docker stop
2.sudo su切換到root身份,cd /var/lib/docker/containers/容器id/,進(jìn)入對(duì)應(yīng)容器目錄
3.vi hostconfig.json,修改如下,將容器目錄/import綁定到主機(jī)/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.啟動(dòng)docker:/etc/init.d/docker start
最后docker ecec -it 容器id /bin/bash進(jìn)入ls -l /就可以看見import目錄