From d110a065b26fe4b6c7dc962c8850e669374aee1f Mon Sep 17 00:00:00 2001 From: Rio Fujita Date: Sun, 28 Jan 2024 11:32:37 +0900 Subject: [PATCH] Update functions.sh With cgroup v2, CID can be read from /proc/self/mountinfo --- app/functions.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/functions.sh b/app/functions.sh index 56f03f0..65467cc 100644 --- a/app/functions.sh +++ b/app/functions.sh @@ -204,6 +204,10 @@ function get_self_cid { if [[ ( ${#self_cid} != 64 ) && ( -f /proc/self/cgroup ) ]]; then self_cid="$(grep -Eo -m 1 '[[:alnum:]]{64}' /proc/self/cgroup)" fi + # cgroups v2 + if [[ ( ${#self_cid} != 64 ) && ( -f /proc/self/mountinfo ) ]]; then + self_cid="$(grep '/userdata/hostname' /proc/self/mountinfo | grep -Eo '[[:alnum:]]{64}')" + fi if [[ ( ${#self_cid} != 64 ) ]]; then self_cid="$(docker_api "/containers/$(hostname)/json" | jq -r '.Id')" fi