github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/integration-cli/requirements_unix_test.go (about) 1 // +build !windows 2 3 package main 4 5 import ( 6 "bytes" 7 "io/ioutil" 8 "os/exec" 9 "strings" 10 11 "github.com/docker/docker/pkg/parsers/kernel" 12 "github.com/docker/docker/pkg/sysinfo" 13 ) 14 15 var ( 16 // SysInfo stores information about which features a kernel supports. 17 SysInfo *sysinfo.SysInfo 18 ) 19 20 func cpuCfsPeriod() bool { 21 return testEnv.DaemonInfo.CPUCfsPeriod 22 } 23 24 func cpuCfsQuota() bool { 25 return testEnv.DaemonInfo.CPUCfsQuota 26 } 27 28 func cpuShare() bool { 29 return testEnv.DaemonInfo.CPUShares 30 } 31 32 func oomControl() bool { 33 return testEnv.DaemonInfo.OomKillDisable 34 } 35 36 func pidsLimit() bool { 37 return SysInfo.PidsLimit 38 } 39 40 func kernelMemorySupport() bool { 41 // TODO remove this once kmem support in RHEL kernels is fixed. See https://github.com/opencontainers/runc/pull/1921 42 daemonV, err := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion) 43 if err != nil { 44 return false 45 } 46 requiredV := kernel.VersionInfo{Kernel: 3, Major: 10} 47 if kernel.CompareKernelVersion(*daemonV, requiredV) < 1 { 48 // On Kernel 3.10 and under, don't consider kernel memory to be supported, 49 // even if the kernel (and thus the daemon) reports it as being supported 50 return false 51 } 52 return testEnv.DaemonInfo.KernelMemory 53 } 54 55 func memoryLimitSupport() bool { 56 return testEnv.DaemonInfo.MemoryLimit 57 } 58 59 func memoryReservationSupport() bool { 60 return SysInfo.MemoryReservation 61 } 62 63 func swapMemorySupport() bool { 64 return testEnv.DaemonInfo.SwapLimit 65 } 66 67 func memorySwappinessSupport() bool { 68 return testEnv.IsLocalDaemon() && SysInfo.MemorySwappiness 69 } 70 71 func blkioWeight() bool { 72 return testEnv.IsLocalDaemon() && SysInfo.BlkioWeight 73 } 74 75 func cgroupCpuset() bool { 76 return testEnv.DaemonInfo.CPUSet 77 } 78 79 func seccompEnabled() bool { 80 return supportsSeccomp && SysInfo.Seccomp 81 } 82 83 func bridgeNfIptables() bool { 84 return !SysInfo.BridgeNFCallIPTablesDisabled 85 } 86 87 func unprivilegedUsernsClone() bool { 88 content, err := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone") 89 return err != nil || !strings.Contains(string(content), "0") 90 } 91 92 func overlayFSSupported() bool { 93 cmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "cat /proc/filesystems") 94 out, err := cmd.CombinedOutput() 95 if err != nil { 96 return false 97 } 98 return bytes.Contains(out, []byte("overlay\n")) 99 } 100 101 func init() { 102 if testEnv.IsLocalDaemon() { 103 SysInfo = sysinfo.New(true) 104 } 105 }