Skip to content

Commit d110a06

Browse files
authored
Update functions.sh
With cgroup v2, CID can be read from /proc/self/mountinfo
1 parent 013005a commit d110a06

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/functions.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ function get_self_cid {
204204
if [[ ( ${#self_cid} != 64 ) && ( -f /proc/self/cgroup ) ]]; then
205205
self_cid="$(grep -Eo -m 1 '[[:alnum:]]{64}' /proc/self/cgroup)"
206206
fi
207+
# cgroups v2
208+
if [[ ( ${#self_cid} != 64 ) && ( -f /proc/self/mountinfo ) ]]; then
209+
self_cid="$(grep '/userdata/hostname' /proc/self/mountinfo | grep -Eo '[[:alnum:]]{64}')"
210+
fi
207211
if [[ ( ${#self_cid} != 64 ) ]]; then
208212
self_cid="$(docker_api "/containers/$(hostname)/json" | jq -r '.Id')"
209213
fi

0 commit comments

Comments
 (0)