How to check if process runs within a docker container (cgroup v2 linux host)
How to check if a process is running from within a Docker container? I'd like a method that works reliably, and that is future-proof. This was already asked and answered at How to determine if a process runs inside lxc/Docker?, however the answer is quite old, and it does not seem to work on a recent setup (Linux host with cgroups v2 enabled, Docker 20.10.x, kernel 5.10.x). The top-rated answer (from the link above) suggests to check for the string docker in /proc/1/cgroup, however here's what I get: # cat /proc/1/cgroup 0::/ It seems to be due to the fact that cgroups v2 is enabled on my host
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.