diff --git a/container/libcontainer/handler.go b/container/libcontainer/handler.go index 6e8a73432a..25076d16eb 100644 --- a/container/libcontainer/handler.go +++ b/container/libcontainer/handler.go @@ -793,7 +793,12 @@ func setMemoryStats(s *cgroups.Stats, ret *info.ContainerStats) { ret.Memory.MaxUsage = s.MemoryStats.Usage.MaxUsage ret.Memory.Failcnt = s.MemoryStats.Usage.Failcnt - if s.MemoryStats.UseHierarchy { + if cgroups.IsCgroup2UnifiedMode() { + ret.Memory.Cache = s.MemoryStats.Stats["file"] + ret.Memory.RSS = s.MemoryStats.Stats["anon"] + ret.Memory.Swap = s.MemoryStats.SwapUsage.Usage + ret.Memory.MappedFile = s.MemoryStats.Stats["file_mapped"] + } else if s.MemoryStats.UseHierarchy { ret.Memory.Cache = s.MemoryStats.Stats["total_cache"] ret.Memory.RSS = s.MemoryStats.Stats["total_rss"] ret.Memory.Swap = s.MemoryStats.Stats["total_swap"]