Skip to content

Commit

Permalink
Update functions.sh
Browse files Browse the repository at this point in the history
With cgroup v2, CID can be read from /proc/self/mountinfo
  • Loading branch information
rioriost authored Jan 28, 2024
1 parent 013005a commit d110a06
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d110a06

Please sign in to comment.