File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 2020def resolve_container_path (container_path ):
2121 container_path = os .path .realpath (container_path )
2222 try :
23- with open ('/proc/self/cgroup' ) as f :
24- # Entries in /proc/self/cgroup look like this (note the nesting):
25- # 11:name=systemd:/docker/82c1bd2…23b5bcf/docker/6547bce…60ca5a7
26- prefix , container_id = next (f ).strip ().split (':' )[2 ].split ('/' )[- 2 :]
23+ with open ('/proc/self/mountinfo' ) as f :
24+ prefix = '/docker/containers/'
25+ for line in f :
26+ if prefix in line :
27+ parts = line .split (prefix )
28+ if len (parts ) > 1 :
29+ container_id = parts [1 ].split ('/' )[0 ]
2730 except FileNotFoundError :
2831 pass
2932 else :
30- if prefix == ' docker' :
33+ if prefix . startswith ( '/ docker') :
3134 api = docker .client .from_env ().api
3235 for mount in api .inspect_container (container_id )['Mounts' ]:
3336 if container_path .startswith (mount ['Destination' ]):
You can’t perform that action at this time.
0 commit comments