mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
9f0b3f5609
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
41 lines
1,003 B
Go
41 lines
1,003 B
Go
package requirement // import "github.com/docker/docker/integration/internal/requirement"
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
|
"gotest.tools/v3/icmd"
|
|
)
|
|
|
|
// CgroupNamespacesEnabled checks if cgroup namespaces are enabled on this host
|
|
func CgroupNamespacesEnabled() bool {
|
|
if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func overlayFSSupported() bool {
|
|
result := icmd.RunCommand("/bin/sh", "-c", "cat /proc/filesystems")
|
|
if result.Error != nil {
|
|
return false
|
|
}
|
|
return strings.Contains(result.Combined(), "overlay\n")
|
|
}
|
|
|
|
// Overlay2Supported returns true if the current system supports overlay2 as graphdriver
|
|
func Overlay2Supported(kernelVersion string) bool {
|
|
if !overlayFSSupported() {
|
|
return false
|
|
}
|
|
|
|
daemonV, err := kernel.ParseRelease(kernelVersion)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
requiredV := kernel.VersionInfo{Kernel: 4}
|
|
return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
|
|
|
|
}
|