diff --git a/app/utils/system.py b/app/utils/system.py index 3b198bf1..f661b403 100644 --- a/app/utils/system.py +++ b/app/utils/system.py @@ -354,6 +354,12 @@ class SystemUtils: 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 len(container_id) < 20: + index_resolv_conf = data.find("/sys/fs/cgroup/devices") + if index_resolv_conf != -1: + 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: return False, "获取容器ID失败!" # 重启当前容器