How to get container ID from within the container with cgroup v2

hi Team.

Do you know by any chance how to get container ID from within the container with cgroup v2? Tried to find a solution in google, problem is well-know (couple of topics on stackoverflow) but no solution as of now.

Perhaps someone has a working command?

thx!

Can you share why you need to know the container id inside the container itself?

I remembered an issue wich was related to cgroup v2 and commands in the container, I am not sure that helps, but I leave it here anyway

And now that I shared this link I realized I already answered a question related to getting the container id which might help you as well

You could for example save the cid file in a folder that is mounted into the container so you just read a file in the container that you mounted.