diff --git a/libcontainer/cgroups/systemd/v2.go b/libcontainer/cgroups/systemd/v2.go index 4af958f4fd5..49c0bfab623 100644 --- a/libcontainer/cgroups/systemd/v2.go +++ b/libcontainer/cgroups/systemd/v2.go @@ -3,7 +3,6 @@ package systemd import ( "fmt" "math" - "os" "path/filepath" "strconv" "strings" @@ -301,9 +300,10 @@ func (m *unifiedManager) Destroy() error { return err } - // XXX this is probably not needed, systemd should handle it - err := os.Remove(m.path) - if err != nil && !os.IsNotExist(err) { + // systemd 239 do not remove sub-cgroups. + err := m.fsMgr.Destroy() + // fsMgr.Destroy has handled ErrNotExist + if err != nil { return err }