2018-08-02 13:24:51 -07:00
|
|
|
package requirement // import "github.com/docker/docker/integration/internal/requirement"
|
|
|
|
|
|
|
|
import (
|
2019-03-14 20:44:18 -07:00
|
|
|
"os"
|
2018-08-02 13:24:51 -07:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2020-02-07 14:39:24 +01:00
|
|
|
"gotest.tools/v3/icmd"
|
2018-08-02 13:24:51 -07:00
|
|
|
)
|
|
|
|
|
2019-03-14 20:44:18 -07:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2018-08-02 13:24:51 -07:00
|
|
|
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
|
|
|
|
|
|
|
|
}
|