[英]How does Docker App Running Inside Container 1 should read file from Container 2 which is Volume Mounted to Host Machine
[英]How to Distinguish between mounted volume and image native directory in Docker
如果我在Docker中安裝卷
docker run -v /folder1:/folder1 [imageid]
代碼中是否有辦法告訴/ folder1是已安裝的卷而不是映像本機文件夾?
喜歡
new DirectoryInfo("/folder1")
我不熟悉C#,但是如果可以訪問/proc
下的文件,則可以檢查文件/proc/self/mountinfo
。
如果目錄來自映像本身,則將其安裝為overlay
。
如果在運行時創建目錄,則將其安裝為proc | tmpfs | sysfs | devpts | mqueue | cgroup
proc | tmpfs | sysfs | devpts | mqueue | cgroup
proc | tmpfs | sysfs | devpts | mqueue | cgroup
。
如果排除這些安裝類型,則/proc/self/mountinfo
行將是您安裝的卷。 簡而言之,此命令適用於我的情況:
cat /proc/self/mountinfo | grep -v 'proc\|tmpfs\|sysfs\|devpts\|mqueue\|cgroup\|overlay'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.