Reputation: 10749
If I mount a volume in docker
docker run -v /folder1:/folder1 [imageid]
Is there a way in code to tell /folder1 is a mounted volume and not an image native folder?
Like
new DirectoryInfo("/folder1")
Upvotes: 0
Views: 165
Reputation: 1525
I am not familar with C#, but if you can access file under /proc
, you can check file /proc/self/mountinfo
.
If a dir is from image itself, it is mount as overlay
.
If a dir is create at runtime, it is mount as proc | tmpfs | sysfs | devpts | mqueue | cgroup
.
If we exclude these mount type, the rest of lines in /proc/self/mountinfo
will be the volume you mount. In short, this command works in my situation:
cat /proc/self/mountinfo | grep -v 'proc\|tmpfs\|sysfs\|devpts\|mqueue\|cgroup\|overlay'
Upvotes: 1