Skip to content

Commit

Permalink
Merge pull request #1092 from rioriost/main
Browse files Browse the repository at this point in the history
fix: get container ID from /proc/self/mountinfo (for podman)
  • Loading branch information
buchdag authored May 4, 2024
2 parents 624a9ec + cf43aca commit c99e656
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,15 @@ function get_self_cid {

# Try the /proc files methods first then resort to the Docker API.
if [[ -f /proc/1/cpuset ]]; then
self_cid="$(grep -Eo '[[:alnum:]]{64}' /proc/1/cpuset)"
self_cid="$(grep -Eo -m 1 '[[:alnum:]]{64}' /proc/1/cpuset)"
fi
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 -m 1 '[[: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 c99e656

Please sign in to comment.