Merge pull request #654 from DDS-Derek/main

fix: container id retrieval error
This commit is contained in:
jxxghp
2023-09-23 16:21:05 +08:00
committed by GitHub

View File

@ -343,9 +343,9 @@ class SystemUtils:
# 获取当前容器的 ID
with open('/proc/self/mountinfo', 'r') as f:
data = f.read()
index_resolv_conf = data.find("resolv.conf")
index_resolv_conf = data.find("/sys/fs/cgroup/devices")
if index_resolv_conf != -1:
index_second_slash = data.rfind("/", 0, index_resolv_conf)
index_second_slash = data.rfind(" ", 0, index_resolv_conf)
index_first_slash = data.rfind("/", 0, index_second_slash) + 1
container_id = data[index_first_slash:index_second_slash]
if not container_id: