@@ -10,6 +10,7 @@ import (
1010 "os"
1111 "os/exec"
1212 "path"
13+ "strconv"
1314 "strings"
1415 "syscall"
1516
@@ -21,6 +22,7 @@ import (
2122 "github.com/docker/docker/pkg/directory"
2223 "github.com/docker/docker/pkg/idtools"
2324 "github.com/docker/docker/pkg/mount"
25+ "github.com/docker/docker/pkg/parsers"
2426 "github.com/docker/docker/pkg/parsers/kernel"
2527
2628 "github.com/opencontainers/runc/libcontainer/label"
@@ -92,6 +94,10 @@ func init() {
9294// If overlay filesystem is not supported on the host, graphdriver.ErrNotSupported is returned as error.
9395// If a overlay filesystem is not supported over a existing filesystem then error graphdriver.ErrIncompatibleFS is returned.
9496func Init (home string , options []string , uidMaps , gidMaps []idtools.IDMap ) (graphdriver.Driver , error ) {
97+ opts , err := parseOptions (options )
98+ if err != nil {
99+ return nil , err
100+ }
95101
96102 if err := supportsOverlay (); err != nil {
97103 return nil , graphdriver .ErrNotSupported
@@ -103,7 +109,10 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
103109 return nil , err
104110 }
105111 if kernel .CompareKernelVersion (* v , kernel.VersionInfo {Kernel : 4 , Major : 0 , Minor : 0 }) < 0 {
106- return nil , graphdriver .ErrNotSupported
112+ if ! opts .overrideKernelCheck {
113+ return nil , graphdriver .ErrNotSupported
114+ }
115+ logrus .Warnf ("Using pre-4.0.0 kernel for overlay2, mount failures may require kernel update" )
107116 }
108117
109118 fsMagic , err := graphdriver .GetFSMagic (home )
@@ -144,6 +153,31 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
144153 return d , nil
145154}
146155
156+ type overlayOptions struct {
157+ overrideKernelCheck bool
158+ }
159+
160+ func parseOptions (options []string ) (* overlayOptions , error ) {
161+ o := & overlayOptions {}
162+ for _ , option := range options {
163+ key , val , err := parsers .ParseKeyValueOpt (option )
164+ if err != nil {
165+ return nil , err
166+ }
167+ key = strings .ToLower (key )
168+ switch key {
169+ case "overlay2.override_kernel_check" :
170+ o .overrideKernelCheck , err = strconv .ParseBool (val )
171+ if err != nil {
172+ return nil , err
173+ }
174+ default :
175+ return nil , fmt .Errorf ("overlay2: Unknown option %s\n " , key )
176+ }
177+ }
178+ return o , nil
179+ }
180+
147181func supportsOverlay () error {
148182 // We can try to modprobe overlay first before looking at
149183 // proc/filesystems for when overlay is supported
0 commit comments