Is there a way to get the cgroup root path(s) for a podman container?
It seems podman inspect
does not reveal anything about cgroups.
One "hacky" way I've found is to do something like
# Run the container, writing its container ID to /tmp/cid
podman run --rm -it --cidfile=/tmp/cid busybox
# Search /sys/fs/cgroup for the CID
cid=$(cat /tmp/cid)
find /sys/fs/cgroup | grep "/libpod-$cid/" | grep '/cpu,cpuacct/' | grep '/cpuacct.usage'
# prints something like: /sys/fs/cgroup/cpu,cpuacct/libpod_parent/libpod-abc123.../cpuacct.usage
But I am not happy with this solution, because:
- It requires an inefficient search (
find
) - I'm not sure whether the search path of
/sys/fs/cgroup
is guaranteed to be correct - If cgroup v2 is in use, the file I am looking for might have a different basename (for example, it might be
memory.current
instead ofmemory.usage_in_bytes
for cgroup v2)
Is there a more direct way using podman or perhaps one of the Go SDKs to get this information?