Browse code

LCOW: Add environment variable to enable

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2017/04/25 02:28:21
Showing 6 changed files
... ...
@@ -40,6 +40,7 @@ import (
40 40
 	"github.com/docker/docker/pkg/pidfile"
41 41
 	"github.com/docker/docker/pkg/plugingetter"
42 42
 	"github.com/docker/docker/pkg/signal"
43
+	"github.com/docker/docker/pkg/system"
43 44
 	"github.com/docker/docker/plugin"
44 45
 	"github.com/docker/docker/registry"
45 46
 	"github.com/docker/docker/runconfig"
... ...
@@ -210,6 +211,10 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
210 210
 		logrus.Fatalf("Error creating middlewares: %v", err)
211 211
 	}
212 212
 
213
+	if system.LCOWSupported() {
214
+		logrus.Warnln("LCOW support is enabled - this feature is incomplete")
215
+	}
216
+
213 217
 	d, err := daemon.NewDaemon(cli.Config, registryService, containerdRemote, pluginStore)
214 218
 	if err != nil {
215 219
 		return fmt.Errorf("Error starting daemon: %v", err)
... ...
@@ -14,6 +14,7 @@ import (
14 14
 	"github.com/docker/docker/image"
15 15
 	"github.com/docker/docker/layer"
16 16
 	"github.com/docker/docker/pkg/progress"
17
+	"github.com/docker/docker/pkg/system"
17 18
 	refstore "github.com/docker/docker/reference"
18 19
 	"github.com/docker/docker/registry"
19 20
 	"github.com/docker/libtrust"
... ...
@@ -143,8 +144,8 @@ func (s *imageConfigStore) RootFSFromConfig(c []byte) (*image.RootFS, error) {
143 143
 	}
144 144
 
145 145
 	// fail immediately on Windows when downloading a non-Windows image
146
-	// and vice versa
147
-	if runtime.GOOS == "windows" && unmarshalledConfig.OS == "linux" {
146
+	// and vice versa. Exception on Windows if Linux Containers are enabled.
147
+	if runtime.GOOS == "windows" && unmarshalledConfig.OS == "linux" && !system.LCOWSupported() {
148 148
 		return nil, fmt.Errorf("image operating system %q cannot be used on this platform", unmarshalledConfig.OS)
149 149
 	} else if runtime.GOOS != "windows" && unmarshalledConfig.OS == "windows" {
150 150
 		return nil, fmt.Errorf("image operating system %q cannot be used on this platform", unmarshalledConfig.OS)
... ...
@@ -2,26 +2,9 @@ package system
2 2
 
3 3
 import (
4 4
 	"os"
5
-	"syscall"
6 5
 	"time"
7
-	"unsafe"
8 6
 )
9 7
 
10
-var (
11
-	maxTime time.Time
12
-)
13
-
14
-func init() {
15
-	if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 {
16
-		// This is a 64 bit timespec
17
-		// os.Chtimes limits time to the following
18
-		maxTime = time.Unix(0, 1<<63-1)
19
-	} else {
20
-		// This is a 32 bit timespec
21
-		maxTime = time.Unix(1<<31-1, 0)
22
-	}
23
-}
24
-
25 8
 // Chtimes changes the access time and modified time of a file at the given path
26 9
 func Chtimes(name string, atime time.Time, mtime time.Time) error {
27 10
 	unixMinTime := time.Unix(0, 0)
28 11
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+package system
1
+
2
+import (
3
+	"syscall"
4
+	"time"
5
+	"unsafe"
6
+)
7
+
8
+// Used by chtimes
9
+var maxTime time.Time
10
+
11
+func init() {
12
+	// chtimes initialization
13
+	if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 {
14
+		// This is a 64 bit timespec
15
+		// os.Chtimes limits time to the following
16
+		maxTime = time.Unix(0, 1<<63-1)
17
+	} else {
18
+		// This is a 32 bit timespec
19
+		maxTime = time.Unix(1<<31-1, 0)
20
+	}
21
+}
0 22
new file mode 100644
... ...
@@ -0,0 +1,17 @@
0
+package system
1
+
2
+import "os"
3
+
4
+// LCOWSupported determines if Linux Containers on Windows are supported.
5
+// Note: This feature is in development (06/17) and enabled through an
6
+// environment variable. At a future time, it will be enabled based
7
+// on build number. @jhowardmsft
8
+var lcowSupported = false
9
+
10
+func init() {
11
+	// LCOW initialization
12
+	if os.Getenv("LCOW_SUPPORTED") != "" {
13
+		lcowSupported = true
14
+	}
15
+
16
+}
0 17
new file mode 100644
... ...
@@ -0,0 +1,6 @@
0
+package system
1
+
2
+// LCOWSupported returns true if Linux containers on Windows are supported.
3
+func LCOWSupported() bool {
4
+	return lcowSupported
5
+}