def container_id(pid)
cgroup_file = "/proc/#{pid}/cgroup"
return nil unless File.exist?(cgroup_file)
container_id = File.foreach(cgroup_file)
.map(&:strip)
.select { |cg| cg.match?(/docker/) }.first
container_id.split('/').last
end
Created
June 30, 2022 08:29
-
-
Save gagomes/bcea1a691c4a396538ad683d08dc1243 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment