github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/integration/internal/requirement/requirement_linux.go (about) 1 package requirement // import "github.com/demonoid81/moby/integration/internal/requirement" 2 3 import ( 4 "os" 5 "strings" 6 7 "github.com/demonoid81/moby/pkg/parsers/kernel" 8 "gotest.tools/v3/icmd" 9 ) 10 11 // CgroupNamespacesEnabled checks if cgroup namespaces are enabled on this host 12 func CgroupNamespacesEnabled() bool { 13 if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) { 14 return false 15 } 16 17 return true 18 } 19 20 func overlayFSSupported() bool { 21 result := icmd.RunCommand("/bin/sh", "-c", "cat /proc/filesystems") 22 if result.Error != nil { 23 return false 24 } 25 return strings.Contains(result.Combined(), "overlay\n") 26 } 27 28 // Overlay2Supported returns true if the current system supports overlay2 as graphdriver 29 func Overlay2Supported(kernelVersion string) bool { 30 if !overlayFSSupported() { 31 return false 32 } 33 34 daemonV, err := kernel.ParseRelease(kernelVersion) 35 if err != nil { 36 return false 37 } 38 requiredV := kernel.VersionInfo{Kernel: 4} 39 return kernel.CompareKernelVersion(*daemonV, requiredV) > -1 40 41 }