Browse code

Windows: First part of CI tests (docker run)

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

John Howard authored on 2015/09/02 06:37:04
Showing 6 changed files
... ...
@@ -1028,7 +1028,7 @@ func (s *DockerSuite) TestContainerApiRestart(c *check.C) {
1028 1028
 	c.Assert(err, check.IsNil)
1029 1029
 	c.Assert(status, check.Equals, http.StatusNoContent)
1030 1030
 
1031
-	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5); err != nil {
1031
+	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5*time.Second); err != nil {
1032 1032
 		c.Fatal(err)
1033 1033
 	}
1034 1034
 }
... ...
@@ -1044,7 +1044,7 @@ func (s *DockerSuite) TestContainerApiRestartNotimeoutParam(c *check.C) {
1044 1044
 	c.Assert(err, check.IsNil)
1045 1045
 	c.Assert(status, check.Equals, http.StatusNoContent)
1046 1046
 
1047
-	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5); err != nil {
1047
+	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5*time.Second); err != nil {
1048 1048
 		c.Fatal(err)
1049 1049
 	}
1050 1050
 }
... ...
@@ -1082,7 +1082,7 @@ func (s *DockerSuite) TestContainerApiStop(c *check.C) {
1082 1082
 	c.Assert(err, check.IsNil)
1083 1083
 	c.Assert(status, check.Equals, http.StatusNoContent)
1084 1084
 
1085
-	if err := waitInspect(name, "{{ .State.Running  }}", "false", 5); err != nil {
1085
+	if err := waitInspect(name, "{{ .State.Running  }}", "false", 5*time.Second); err != nil {
1086 1086
 		c.Fatal(err)
1087 1087
 	}
1088 1088
 
... ...
@@ -1101,7 +1101,7 @@ func (s *DockerSuite) TestContainerApiWait(c *check.C) {
1101 1101
 	c.Assert(err, check.IsNil)
1102 1102
 	c.Assert(status, check.Equals, http.StatusOK)
1103 1103
 
1104
-	if err := waitInspect(name, "{{ .State.Running  }}", "false", 5); err != nil {
1104
+	if err := waitInspect(name, "{{ .State.Running  }}", "false", 5*time.Second); err != nil {
1105 1105
 		c.Fatal(err)
1106 1106
 	}
1107 1107
 
... ...
@@ -1347,7 +1347,7 @@ func (s *DockerSuite) TestPostContainerStop(c *check.C) {
1347 1347
 	// 204 No Content is expected, not 200
1348 1348
 	c.Assert(statusCode, check.Equals, http.StatusNoContent)
1349 1349
 
1350
-	if err := waitInspect(containerID, "{{ .State.Running  }}", "false", 5); err != nil {
1350
+	if err := waitInspect(containerID, "{{ .State.Running  }}", "false", 5*time.Second); err != nil {
1351 1351
 		c.Fatal(err)
1352 1352
 	}
1353 1353
 }
... ...
@@ -2,6 +2,7 @@ package main
2 2
 
3 3
 import (
4 4
 	"strings"
5
+	"time"
5 6
 
6 7
 	"github.com/go-check/check"
7 8
 )
... ...
@@ -132,7 +133,7 @@ func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
132 132
 	out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
133 133
 
134 134
 	id := strings.TrimSpace(string(out))
135
-	if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 5); err != nil {
135
+	if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 5*time.Second); err != nil {
136 136
 		c.Fatal(err)
137 137
 	}
138 138
 	count, err := inspectField(id, "RestartCount")
... ...
@@ -25,23 +25,22 @@ import (
25 25
 
26 26
 // "test123" should be printed by docker run
27 27
 func (s *DockerSuite) TestRunEchoStdout(c *check.C) {
28
-	testRequires(c, DaemonIsLinux)
29 28
 	out, _ := dockerCmd(c, "run", "busybox", "echo", "test123")
30 29
 	if out != "test123\n" {
31
-		c.Fatalf("container should've printed 'test123'")
30
+		c.Fatalf("container should've printed 'test123', got '%s'", out)
32 31
 	}
33 32
 }
34 33
 
35 34
 // "test" should be printed
36 35
 func (s *DockerSuite) TestRunEchoNamedContainer(c *check.C) {
37
-	testRequires(c, DaemonIsLinux)
38 36
 	out, _ := dockerCmd(c, "run", "--name", "testfoonamedcontainer", "busybox", "echo", "test")
39 37
 	if out != "test\n" {
40 38
 		c.Errorf("container should've printed 'test'")
41 39
 	}
42 40
 }
43 41
 
44
-// docker run should not leak file descriptors
42
+// docker run should not leak file descriptors. This test relies on Unix
43
+// specific functionality and cannot run on Windows.
45 44
 func (s *DockerSuite) TestRunLeakyFileDescriptors(c *check.C) {
46 45
 	testRequires(c, DaemonIsLinux)
47 46
 	out, _ := dockerCmd(c, "run", "busybox", "ls", "-C", "/proc/self/fd")
... ...
@@ -55,34 +54,37 @@ func (s *DockerSuite) TestRunLeakyFileDescriptors(c *check.C) {
55 55
 // it should be possible to lookup Google DNS
56 56
 // this will fail when Internet access is unavailable
57 57
 func (s *DockerSuite) TestRunLookupGoogleDns(c *check.C) {
58
-	testRequires(c, DaemonIsLinux)
59 58
 	testRequires(c, Network)
60
-	dockerCmd(c, "run", "busybox", "nslookup", "google.com")
59
+	image := DefaultImage
60
+	if daemonPlatform == "windows" {
61
+		// nslookup isn't present in Windows busybox. Is built-in.
62
+		image = WindowsBaseImage
63
+	}
64
+	dockerCmd(c, "run", image, "nslookup", "google.com")
61 65
 }
62 66
 
63 67
 // the exit code should be 0
64 68
 // some versions of lxc might make this test fail
65 69
 func (s *DockerSuite) TestRunExitCodeZero(c *check.C) {
66
-	testRequires(c, DaemonIsLinux)
67 70
 	dockerCmd(c, "run", "busybox", "true")
68 71
 }
69 72
 
70 73
 // the exit code should be 1
71 74
 // some versions of lxc might make this test fail
72 75
 func (s *DockerSuite) TestRunExitCodeOne(c *check.C) {
73
-	testRequires(c, DaemonIsLinux)
74 76
 	_, exitCode, err := dockerCmdWithError("run", "busybox", "false")
75 77
 	if err != nil && !strings.Contains("exit status 1", fmt.Sprintf("%s", err)) {
76 78
 		c.Fatal(err)
77 79
 	}
78 80
 	if exitCode != 1 {
79
-		c.Errorf("container should've exited with exit code 1")
81
+		c.Errorf("container should've exited with exit code 1. Got %d", exitCode)
80 82
 	}
81 83
 }
82 84
 
83 85
 // it should be possible to pipe in data via stdin to a process running in a container
84 86
 // some versions of lxc might make this test fail
85 87
 func (s *DockerSuite) TestRunStdinPipe(c *check.C) {
88
+	// TODO Windows: This needs some work to make compatible.
86 89
 	testRequires(c, DaemonIsLinux)
87 90
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat")
88 91
 	runCmd.Stdin = strings.NewReader("blahblah")
... ...
@@ -106,7 +108,6 @@ func (s *DockerSuite) TestRunStdinPipe(c *check.C) {
106 106
 
107 107
 // the container's ID should be printed when starting a container in detached mode
108 108
 func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) {
109
-	testRequires(c, DaemonIsLinux)
110 109
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
111 110
 
112 111
 	out = strings.TrimSpace(out)
... ...
@@ -122,25 +123,41 @@ func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) {
122 122
 
123 123
 // the working directory should be set correctly
124 124
 func (s *DockerSuite) TestRunWorkingDirectory(c *check.C) {
125
+	// TODO Windows: There's a Windows bug stopping this from working.
125 126
 	testRequires(c, DaemonIsLinux)
126
-	out, _ := dockerCmd(c, "run", "-w", "/root", "busybox", "pwd")
127
+	dir := "/root"
128
+	image := "busybox"
129
+	if daemonPlatform == "windows" {
130
+		dir = `/windows`
131
+		image = WindowsBaseImage
132
+	}
127 133
 
134
+	// First with -w
135
+	out, _ := dockerCmd(c, "run", "-w", dir, image, "pwd")
128 136
 	out = strings.TrimSpace(out)
129
-	if out != "/root" {
137
+	if out != dir {
130 138
 		c.Errorf("-w failed to set working directory")
131 139
 	}
132 140
 
133
-	out, _ = dockerCmd(c, "run", "--workdir", "/root", "busybox", "pwd")
141
+	// Then with --workdir
142
+	out, _ = dockerCmd(c, "run", "--workdir", dir, image, "pwd")
134 143
 	out = strings.TrimSpace(out)
135
-	if out != "/root" {
144
+	if out != dir {
136 145
 		c.Errorf("--workdir failed to set working directory")
137 146
 	}
138 147
 }
139 148
 
140 149
 // pinging Google's DNS resolver should fail when we disable the networking
141 150
 func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) {
142
-	testRequires(c, DaemonIsLinux)
143
-	out, exitCode, err := dockerCmdWithError("run", "--net=none", "busybox", "ping", "-c", "1", "8.8.8.8")
151
+	count := "-c"
152
+	image := "busybox"
153
+	if daemonPlatform == "windows" {
154
+		count = "-n"
155
+		image = WindowsBaseImage
156
+	}
157
+
158
+	// First using the long form --net
159
+	out, exitCode, err := dockerCmdWithError("run", "--net=none", image, "ping", count, "1", "8.8.8.8")
144 160
 	if err != nil && exitCode != 1 {
145 161
 		c.Fatal(out, err)
146 162
 	}
... ...
@@ -148,7 +165,8 @@ func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) {
148 148
 		c.Errorf("--net=none should've disabled the network; the container shouldn't have been able to ping 8.8.8.8")
149 149
 	}
150 150
 
151
-	out, exitCode, err = dockerCmdWithError("run", "-n=false", "busybox", "ping", "-c", "1", "8.8.8.8")
151
+	// And then with the short form -n
152
+	out, exitCode, err = dockerCmdWithError("run", "-n=false", image, "ping", count, "1", "8.8.8.8")
152 153
 	if err != nil && exitCode != 1 {
153 154
 		c.Fatal(out, err)
154 155
 	}
... ...
@@ -159,6 +177,8 @@ func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) {
159 159
 
160 160
 //test --link use container name to link target
161 161
 func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *check.C) {
162
+	// TODO Windows: This test cannot run on a Windows daemon as the networking
163
+	// settings are not populated back yet on inspect.
162 164
 	testRequires(c, DaemonIsLinux)
163 165
 	dockerCmd(c, "run", "-i", "-t", "-d", "--name", "parent", "busybox")
164 166
 
... ...
@@ -173,6 +193,8 @@ func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *check.C) {
173 173
 
174 174
 //test --link use container id to link target
175 175
 func (s *DockerSuite) TestRunLinksContainerWithContainerId(c *check.C) {
176
+	// TODO Windows: This test cannot run on a Windows daemon as the networking
177
+	// settings are not populated back yet on inspect.
176 178
 	testRequires(c, DaemonIsLinux)
177 179
 	cID, _ := dockerCmd(c, "run", "-i", "-t", "-d", "busybox")
178 180
 
... ...
@@ -188,11 +210,10 @@ func (s *DockerSuite) TestRunLinksContainerWithContainerId(c *check.C) {
188 188
 
189 189
 // Issue 9677.
190 190
 func (s *DockerSuite) TestRunWithDaemonFlags(c *check.C) {
191
-	testRequires(c, DaemonIsLinux)
192
-	out, _, err := dockerCmdWithError("--selinux-enabled", "run", "-i", "-t", "busybox", "true")
191
+	out, _, err := dockerCmdWithError("--exec-opt", "foo=bar", "run", "-i", "-t", "busybox", "true")
193 192
 	if err != nil {
194 193
 		if !strings.Contains(out, "must follow the 'docker daemon' command") && // daemon
195
-			!strings.Contains(out, "flag provided but not defined: --selinux-enabled") { // no daemon (client-only)
194
+			!strings.Contains(out, "flag provided but not defined: --exec-opt") { // no daemon (client-only)
196 195
 			c.Fatal(err, out)
197 196
 		}
198 197
 	}
... ...
@@ -200,6 +221,8 @@ func (s *DockerSuite) TestRunWithDaemonFlags(c *check.C) {
200 200
 
201 201
 // Regression test for #4979
202 202
 func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) {
203
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
204
+	// not support volumes
203 205
 	testRequires(c, DaemonIsLinux)
204 206
 	out, exitCode := dockerCmd(c, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file")
205 207
 	if exitCode != 0 {
... ...
@@ -215,9 +238,9 @@ func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) {
215 215
 // Volume path is a symlink which also exists on the host, and the host side is a file not a dir
216 216
 // But the volume call is just a normal volume, not a bind mount
217 217
 func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
218
-	testRequires(c, DaemonIsLinux)
219
-	testRequires(c, SameHostDaemon)
220
-	testRequires(c, NativeExecDriver)
218
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
219
+	// not support volumes
220
+	testRequires(c, DaemonIsLinux, SameHostDaemon, NativeExecDriver)
221 221
 	name := "test-volume-symlink"
222 222
 
223 223
 	dir, err := ioutil.TempDir("", name)
... ...
@@ -241,6 +264,8 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
241 241
 }
242 242
 
243 243
 func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *check.C) {
244
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
245
+	// not support volumes
244 246
 	testRequires(c, DaemonIsLinux)
245 247
 	if _, code, err := dockerCmdWithError("run", "-v", "/test:/test:ro", "busybox", "touch", "/test/somefile"); err == nil || code == 0 {
246 248
 		c.Fatalf("run should fail because volume is ro: exit code %d", code)
... ...
@@ -248,6 +273,8 @@ func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *check.C) {
248 248
 }
249 249
 
250 250
 func (s *DockerSuite) TestRunVolumesFromInReadonlyMode(c *check.C) {
251
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
252
+	// not support volumes
251 253
 	testRequires(c, DaemonIsLinux)
252 254
 	dockerCmd(c, "run", "--name", "parent", "-v", "/test", "busybox", "true")
253 255
 
... ...
@@ -258,6 +285,8 @@ func (s *DockerSuite) TestRunVolumesFromInReadonlyMode(c *check.C) {
258 258
 
259 259
 // Regression test for #1201
260 260
 func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
261
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
262
+	// not support volumes
261 263
 	testRequires(c, DaemonIsLinux)
262 264
 	dockerCmd(c, "run", "--name", "parent", "-v", "/test", "busybox", "true")
263 265
 	dockerCmd(c, "run", "--volumes-from", "parent:rw", "busybox", "touch", "/test/file")
... ...
@@ -270,6 +299,8 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
270 270
 }
271 271
 
272 272
 func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) {
273
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
274
+	// not support volumes
273 275
 	testRequires(c, DaemonIsLinux)
274 276
 	dockerCmd(c, "run", "--name", "parent", "-v", "/test:/test:ro", "busybox", "true")
275 277
 
... ...
@@ -288,6 +319,8 @@ func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) {
288 288
 
289 289
 // Test for GH#10618
290 290
 func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
291
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
292
+	// not support volumes
291 293
 	testRequires(c, DaemonIsLinux)
292 294
 	mountstr1 := randomUnixTmpDirPath("test1") + ":/someplace"
293 295
 	mountstr2 := randomUnixTmpDirPath("test2") + ":/someplace"
... ...
@@ -303,12 +336,16 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
303 303
 
304 304
 // Test for #1351
305 305
 func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *check.C) {
306
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
307
+	// not support volumes
306 308
 	testRequires(c, DaemonIsLinux)
307 309
 	dockerCmd(c, "run", "--name", "parent", "-v", "/test", "busybox", "touch", "/test/foo")
308 310
 	dockerCmd(c, "run", "--volumes-from", "parent", "-v", "/test", "busybox", "cat", "/test/foo")
309 311
 }
310 312
 
311 313
 func (s *DockerSuite) TestRunMultipleVolumesFrom(c *check.C) {
314
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
315
+	// not support volumes
312 316
 	testRequires(c, DaemonIsLinux)
313 317
 	dockerCmd(c, "run", "--name", "parent1", "-v", "/test", "busybox", "touch", "/test/foo")
314 318
 	dockerCmd(c, "run", "--name", "parent2", "-v", "/other", "busybox", "touch", "/other/bar")
... ...
@@ -317,7 +354,6 @@ func (s *DockerSuite) TestRunMultipleVolumesFrom(c *check.C) {
317 317
 
318 318
 // this tests verifies the ID format for the container
319 319
 func (s *DockerSuite) TestRunVerifyContainerID(c *check.C) {
320
-	testRequires(c, DaemonIsLinux)
321 320
 	out, exit, err := dockerCmdWithError("run", "-d", "busybox", "true")
322 321
 	if err != nil {
323 322
 		c.Fatal(err)
... ...
@@ -337,6 +373,8 @@ func (s *DockerSuite) TestRunVerifyContainerID(c *check.C) {
337 337
 
338 338
 // Test that creating a container with a volume doesn't crash. Regression test for #995.
339 339
 func (s *DockerSuite) TestRunCreateVolume(c *check.C) {
340
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
341
+	// not support volumes
340 342
 	testRequires(c, DaemonIsLinux)
341 343
 	dockerCmd(c, "run", "-v", "/var/lib/data", "busybox", "true")
342 344
 }
... ...
@@ -344,6 +382,8 @@ func (s *DockerSuite) TestRunCreateVolume(c *check.C) {
344 344
 // Test that creating a volume with a symlink in its path works correctly. Test for #5152.
345 345
 // Note that this bug happens only with symlinks with a target that starts with '/'.
346 346
 func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *check.C) {
347
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
348
+	// not support volumes
347 349
 	testRequires(c, DaemonIsLinux)
348 350
 	image := "docker-test-createvolumewithsymlink"
349 351
 
... ...
@@ -379,6 +419,8 @@ func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *check.C) {
379 379
 
380 380
 // Tests that a volume path that has a symlink exists in a container mounting it with `--volumes-from`.
381 381
 func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *check.C) {
382
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
383
+	// not support volumes
382 384
 	testRequires(c, DaemonIsLinux)
383 385
 	name := "docker-test-volumesfromsymlinkpath"
384 386
 
... ...
@@ -404,8 +446,16 @@ func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *check.C) {
404 404
 }
405 405
 
406 406
 func (s *DockerSuite) TestRunExitCode(c *check.C) {
407
-	testRequires(c, DaemonIsLinux)
408
-	_, exit, err := dockerCmdWithError("run", "busybox", "/bin/sh", "-c", "exit 72")
407
+	var (
408
+		exit int
409
+		err  error
410
+	)
411
+	if daemonPlatform == "windows" {
412
+		// FIXME Windows: Work out the bug in busybox why exit doesn't set the exit code.
413
+		_, exit, err = dockerCmdWithError("run", WindowsBaseImage, "cmd", "/s", "/c", "exit 72")
414
+	} else {
415
+		_, exit, err = dockerCmdWithError("run", "busybox", "/bin/sh", "-c", "exit 72")
416
+	}
409 417
 	if err == nil {
410 418
 		c.Fatal("should not have a non nil error")
411 419
 	}
... ...
@@ -414,15 +464,20 @@ func (s *DockerSuite) TestRunExitCode(c *check.C) {
414 414
 	}
415 415
 }
416 416
 
417
-func (s *DockerSuite) TestRunUserDefaultsToRoot(c *check.C) {
418
-	testRequires(c, DaemonIsLinux)
417
+func (s *DockerSuite) TestRunUserDefaults(c *check.C) {
418
+	expected := "uid=0(root) gid=0(root)"
419
+	if daemonPlatform == "windows" {
420
+		expected = "uid=1000(SYSTEM) gid=1000(SYSTEM)"
421
+	}
419 422
 	out, _ := dockerCmd(c, "run", "busybox", "id")
420
-	if !strings.Contains(out, "uid=0(root) gid=0(root)") {
421
-		c.Fatalf("expected root user got %s", out)
423
+	if !strings.Contains(out, expected) {
424
+		c.Fatalf("expected '%s' got %s", expected, out)
422 425
 	}
423 426
 }
424 427
 
425 428
 func (s *DockerSuite) TestRunUserByName(c *check.C) {
429
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
430
+	// not support the use of -u
426 431
 	testRequires(c, DaemonIsLinux)
427 432
 	out, _ := dockerCmd(c, "run", "-u", "root", "busybox", "id")
428 433
 	if !strings.Contains(out, "uid=0(root) gid=0(root)") {
... ...
@@ -431,6 +486,8 @@ func (s *DockerSuite) TestRunUserByName(c *check.C) {
431 431
 }
432 432
 
433 433
 func (s *DockerSuite) TestRunUserByID(c *check.C) {
434
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
435
+	// not support the use of -u
434 436
 	testRequires(c, DaemonIsLinux)
435 437
 	out, _ := dockerCmd(c, "run", "-u", "1", "busybox", "id")
436 438
 	if !strings.Contains(out, "uid=1(daemon) gid=1(daemon)") {
... ...
@@ -439,6 +496,8 @@ func (s *DockerSuite) TestRunUserByID(c *check.C) {
439 439
 }
440 440
 
441 441
 func (s *DockerSuite) TestRunUserByIDBig(c *check.C) {
442
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
443
+	// not support the use of -u
442 444
 	testRequires(c, DaemonIsLinux)
443 445
 	out, _, err := dockerCmdWithError("run", "-u", "2147483648", "busybox", "id")
444 446
 	if err == nil {
... ...
@@ -450,6 +509,8 @@ func (s *DockerSuite) TestRunUserByIDBig(c *check.C) {
450 450
 }
451 451
 
452 452
 func (s *DockerSuite) TestRunUserByIDNegative(c *check.C) {
453
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
454
+	// not support the use of -u
453 455
 	testRequires(c, DaemonIsLinux)
454 456
 	out, _, err := dockerCmdWithError("run", "-u", "-1", "busybox", "id")
455 457
 	if err == nil {
... ...
@@ -461,6 +522,8 @@ func (s *DockerSuite) TestRunUserByIDNegative(c *check.C) {
461 461
 }
462 462
 
463 463
 func (s *DockerSuite) TestRunUserByIDZero(c *check.C) {
464
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
465
+	// not support the use of -u
464 466
 	testRequires(c, DaemonIsLinux)
465 467
 	out, _, err := dockerCmdWithError("run", "-u", "0", "busybox", "id")
466 468
 	if err != nil {
... ...
@@ -472,6 +535,9 @@ func (s *DockerSuite) TestRunUserByIDZero(c *check.C) {
472 472
 }
473 473
 
474 474
 func (s *DockerSuite) TestRunUserNotFound(c *check.C) {
475
+	// TODO Windows: This test cannot run on a Windows daemon as Windows does
476
+	// not support the use of -u
477
+	testRequires(c, DaemonIsLinux)
475 478
 	_, _, err := dockerCmdWithError("run", "-u", "notme", "busybox", "id")
476 479
 	if err == nil {
477 480
 		c.Fatal("unknown user should cause container to fail")
... ...
@@ -479,7 +545,10 @@ func (s *DockerSuite) TestRunUserNotFound(c *check.C) {
479 479
 }
480 480
 
481 481
 func (s *DockerSuite) TestRunTwoConcurrentContainers(c *check.C) {
482
-	testRequires(c, DaemonIsLinux)
482
+	sleepTime := "2"
483
+	if daemonPlatform == "windows" {
484
+		sleepTime = "5" // Make more reliable on Windows
485
+	}
483 486
 	group := sync.WaitGroup{}
484 487
 	group.Add(2)
485 488
 
... ...
@@ -487,7 +556,7 @@ func (s *DockerSuite) TestRunTwoConcurrentContainers(c *check.C) {
487 487
 	for i := 0; i < 2; i++ {
488 488
 		go func() {
489 489
 			defer group.Done()
490
-			_, _, err := dockerCmdWithError("run", "busybox", "sleep", "2")
490
+			_, _, err := dockerCmdWithError("run", "busybox", "sleep", sleepTime)
491 491
 			errChan <- err
492 492
 		}()
493 493
 	}
... ...
@@ -501,6 +570,8 @@ func (s *DockerSuite) TestRunTwoConcurrentContainers(c *check.C) {
501 501
 }
502 502
 
503 503
 func (s *DockerSuite) TestRunEnvironment(c *check.C) {
504
+	// TODO Windows: Environment handling is different between Linux and
505
+	// Windows and this test relies currently on lxc and unix functionality.
504 506
 	testRequires(c, DaemonIsLinux)
505 507
 	cmd := exec.Command(dockerBinary, "run", "-h", "testing", "-e=FALSE=true", "-e=TRUE", "-e=TRICKY", "-e=HOME=", "busybox", "env")
506 508
 	cmd.Env = append(os.Environ(),
... ...
@@ -544,7 +615,10 @@ func (s *DockerSuite) TestRunEnvironment(c *check.C) {
544 544
 }
545 545
 
546 546
 func (s *DockerSuite) TestRunEnvironmentErase(c *check.C) {
547
+	// TODO Windows: Environment handling is different between Linux and
548
+	// Windows and this test relies currently on lxc and unix functionality.
547 549
 	testRequires(c, DaemonIsLinux)
550
+
548 551
 	// Test to make sure that when we use -e on env vars that are
549 552
 	// not set in our local env that they're removed (if present) in
550 553
 	// the container
... ...
@@ -582,7 +656,10 @@ func (s *DockerSuite) TestRunEnvironmentErase(c *check.C) {
582 582
 }
583 583
 
584 584
 func (s *DockerSuite) TestRunEnvironmentOverride(c *check.C) {
585
+	// TODO Windows: Environment handling is different between Linux and
586
+	// Windows and this test relies currently on lxc and unix functionality.
585 587
 	testRequires(c, DaemonIsLinux)
588
+
586 589
 	// Test to make sure that when we use -e on env vars that are
587 590
 	// already in the env that we're overriding them
588 591
 
... ...
@@ -620,11 +697,17 @@ func (s *DockerSuite) TestRunEnvironmentOverride(c *check.C) {
620 620
 }
621 621
 
622 622
 func (s *DockerSuite) TestRunContainerNetwork(c *check.C) {
623
-	testRequires(c, DaemonIsLinux)
624
-	dockerCmd(c, "run", "busybox", "ping", "-c", "1", "127.0.0.1")
623
+	if daemonPlatform == "windows" {
624
+		// Windows busybox does not have ping. Use built in ping instead.
625
+		dockerCmd(c, "run", WindowsBaseImage, "ping", "-n", "1", "127.0.0.1")
626
+	} else {
627
+		dockerCmd(c, "run", "busybox", "ping", "-c", "1", "127.0.0.1")
628
+	}
625 629
 }
626 630
 
627 631
 func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *check.C) {
632
+	// TODO Windows: This is Linux specific as --link is not supported and
633
+	// this will be deprecated in favour of container networking model.
628 634
 	testRequires(c, DaemonIsLinux)
629 635
 	dockerCmd(c, "run", "--name", "linked", "busybox", "true")
630 636
 
... ...
@@ -640,6 +723,7 @@ func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *check.C) {
640 640
 // codepath is executed with "docker run -h <hostname>".  Both were manually
641 641
 // tested, but this testcase takes the simpler path of using "run -h .."
642 642
 func (s *DockerSuite) TestRunFullHostnameSet(c *check.C) {
643
+	// TODO Windows: -h is not yet functional.
643 644
 	testRequires(c, DaemonIsLinux)
644 645
 	out, _ := dockerCmd(c, "run", "-h", "foo.bar.baz", "busybox", "hostname")
645 646
 	if actual := strings.Trim(out, "\r\n"); actual != "foo.bar.baz" {
... ...
@@ -648,6 +732,8 @@ func (s *DockerSuite) TestRunFullHostnameSet(c *check.C) {
648 648
 }
649 649
 
650 650
 func (s *DockerSuite) TestRunPrivilegedCanMknod(c *check.C) {
651
+	// Not applicable for Windows as Windows daemon does not support
652
+	// the concept of --privileged, and mknod is a Unix concept.
651 653
 	testRequires(c, DaemonIsLinux)
652 654
 	out, _ := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
653 655
 	if actual := strings.Trim(out, "\r\n"); actual != "ok" {
... ...
@@ -656,6 +742,8 @@ func (s *DockerSuite) TestRunPrivilegedCanMknod(c *check.C) {
656 656
 }
657 657
 
658 658
 func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *check.C) {
659
+	// Not applicable for Windows as Windows daemon does not support
660
+	// the concept of --privileged, and mknod is a Unix concept.
659 661
 	testRequires(c, DaemonIsLinux)
660 662
 	out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
661 663
 	if actual := strings.Trim(out, "\r\n"); actual != "ok" {
... ...
@@ -664,6 +752,7 @@ func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *check.C) {
664 664
 }
665 665
 
666 666
 func (s *DockerSuite) TestRunCapDropInvalid(c *check.C) {
667
+	// Not applicable for Windows as there is no concept of --cap-drop
667 668
 	testRequires(c, DaemonIsLinux)
668 669
 	out, _, err := dockerCmdWithError("run", "--cap-drop=CHPASS", "busybox", "ls")
669 670
 	if err == nil {
... ...
@@ -672,6 +761,7 @@ func (s *DockerSuite) TestRunCapDropInvalid(c *check.C) {
672 672
 }
673 673
 
674 674
 func (s *DockerSuite) TestRunCapDropCannotMknod(c *check.C) {
675
+	// Not applicable for Windows as there is no concept of --cap-drop or mknod
675 676
 	testRequires(c, DaemonIsLinux)
676 677
 	out, _, err := dockerCmdWithError("run", "--cap-drop=MKNOD", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
677 678
 
... ...
@@ -684,6 +774,7 @@ func (s *DockerSuite) TestRunCapDropCannotMknod(c *check.C) {
684 684
 }
685 685
 
686 686
 func (s *DockerSuite) TestRunCapDropCannotMknodLowerCase(c *check.C) {
687
+	// Not applicable for Windows as there is no concept of --cap-drop or mknod
687 688
 	testRequires(c, DaemonIsLinux)
688 689
 	out, _, err := dockerCmdWithError("run", "--cap-drop=mknod", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
689 690
 
... ...
@@ -696,6 +787,7 @@ func (s *DockerSuite) TestRunCapDropCannotMknodLowerCase(c *check.C) {
696 696
 }
697 697
 
698 698
 func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *check.C) {
699
+	// Not applicable for Windows as there is no concept of --cap-drop or mknod
699 700
 	testRequires(c, DaemonIsLinux)
700 701
 	out, _, err := dockerCmdWithError("run", "--cap-drop=ALL", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
701 702
 	if err == nil {
... ...
@@ -707,6 +799,7 @@ func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *check.C) {
707 707
 }
708 708
 
709 709
 func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *check.C) {
710
+	// Not applicable for Windows as there is no concept of --cap-drop or mknod
710 711
 	testRequires(c, DaemonIsLinux)
711 712
 	out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=MKNOD", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
712 713
 
... ...
@@ -716,6 +809,7 @@ func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *check.C) {
716 716
 }
717 717
 
718 718
 func (s *DockerSuite) TestRunCapAddInvalid(c *check.C) {
719
+	// Not applicable for Windows as there is no concept of --cap-add
719 720
 	testRequires(c, DaemonIsLinux)
720 721
 	out, _, err := dockerCmdWithError("run", "--cap-add=CHPASS", "busybox", "ls")
721 722
 	if err == nil {
... ...
@@ -724,6 +818,7 @@ func (s *DockerSuite) TestRunCapAddInvalid(c *check.C) {
724 724
 }
725 725
 
726 726
 func (s *DockerSuite) TestRunCapAddCanDownInterface(c *check.C) {
727
+	// Not applicable for Windows as there is no concept of --cap-add
727 728
 	testRequires(c, DaemonIsLinux)
728 729
 	out, _ := dockerCmd(c, "run", "--cap-add=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
729 730
 
... ...
@@ -733,6 +828,7 @@ func (s *DockerSuite) TestRunCapAddCanDownInterface(c *check.C) {
733 733
 }
734 734
 
735 735
 func (s *DockerSuite) TestRunCapAddALLCanDownInterface(c *check.C) {
736
+	// Not applicable for Windows as there is no concept of --cap-add
736 737
 	testRequires(c, DaemonIsLinux)
737 738
 	out, _ := dockerCmd(c, "run", "--cap-add=ALL", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
738 739
 
... ...
@@ -742,6 +838,7 @@ func (s *DockerSuite) TestRunCapAddALLCanDownInterface(c *check.C) {
742 742
 }
743 743
 
744 744
 func (s *DockerSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *check.C) {
745
+	// Not applicable for Windows as there is no concept of --cap-add
745 746
 	testRequires(c, DaemonIsLinux)
746 747
 	out, _, err := dockerCmdWithError("run", "--cap-add=ALL", "--cap-drop=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
747 748
 	if err == nil {
... ...
@@ -753,8 +850,8 @@ func (s *DockerSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *check.C) {
753 753
 }
754 754
 
755 755
 func (s *DockerSuite) TestRunGroupAdd(c *check.C) {
756
-	testRequires(c, DaemonIsLinux)
757
-	testRequires(c, NativeExecDriver)
756
+	// Not applicable for Windows as there is no concept of --group-add
757
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
758 758
 	out, _ := dockerCmd(c, "run", "--group-add=audio", "--group-add=dbus", "--group-add=777", "busybox", "sh", "-c", "id")
759 759
 
760 760
 	groupsList := "uid=0(root) gid=0(root) groups=10(wheel),29(audio),81(dbus),777"
... ...
@@ -764,6 +861,7 @@ func (s *DockerSuite) TestRunGroupAdd(c *check.C) {
764 764
 }
765 765
 
766 766
 func (s *DockerSuite) TestRunPrivilegedCanMount(c *check.C) {
767
+	// Not applicable for Windows as there is no concept of --privileged
767 768
 	testRequires(c, DaemonIsLinux)
768 769
 	out, _ := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
769 770
 
... ...
@@ -773,6 +871,7 @@ func (s *DockerSuite) TestRunPrivilegedCanMount(c *check.C) {
773 773
 }
774 774
 
775 775
 func (s *DockerSuite) TestRunUnprivilegedCannotMount(c *check.C) {
776
+	// Not applicable for Windows as there is no concept of unprivileged
776 777
 	testRequires(c, DaemonIsLinux)
777 778
 	out, _, err := dockerCmdWithError("run", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
778 779
 
... ...
@@ -785,6 +884,7 @@ func (s *DockerSuite) TestRunUnprivilegedCannotMount(c *check.C) {
785 785
 }
786 786
 
787 787
 func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *check.C) {
788
+	// Not applicable for Windows as there is no concept of unprivileged
788 789
 	testRequires(c, DaemonIsLinux)
789 790
 	if _, code, err := dockerCmdWithError("run", "busybox", "touch", "/sys/kernel/profiling"); err == nil || code == 0 {
790 791
 		c.Fatal("sys should not be writable in a non privileged container")
... ...
@@ -792,6 +892,7 @@ func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *check.C)
792 792
 }
793 793
 
794 794
 func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *check.C) {
795
+	// Not applicable for Windows as there is no concept of unprivileged
795 796
 	testRequires(c, DaemonIsLinux)
796 797
 	if _, code, err := dockerCmdWithError("run", "--privileged", "busybox", "touch", "/sys/kernel/profiling"); err != nil || code != 0 {
797 798
 		c.Fatalf("sys should be writable in privileged container")
... ...
@@ -799,6 +900,7 @@ func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *check.C) {
799 799
 }
800 800
 
801 801
 func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *check.C) {
802
+	// Not applicable for Windows as there is no concept of unprivileged
802 803
 	testRequires(c, DaemonIsLinux)
803 804
 	if _, code, err := dockerCmdWithError("run", "busybox", "touch", "/proc/sysrq-trigger"); err == nil || code == 0 {
804 805
 		c.Fatal("proc should not be writable in a non privileged container")
... ...
@@ -806,6 +908,7 @@ func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *check.C
806 806
 }
807 807
 
808 808
 func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *check.C) {
809
+	// Not applicable for Windows as there is no concept of --privileged
809 810
 	testRequires(c, DaemonIsLinux)
810 811
 	if _, code := dockerCmd(c, "run", "--privileged", "busybox", "touch", "/proc/sysrq-trigger"); code != 0 {
811 812
 		c.Fatalf("proc should be writable in privileged container")
... ...
@@ -813,6 +916,7 @@ func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *check.C) {
813 813
 }
814 814
 
815 815
 func (s *DockerSuite) TestRunDeviceNumbers(c *check.C) {
816
+	// Not applicable on Windows as /dev/ is a Unix specific concept
816 817
 	testRequires(c, DaemonIsLinux)
817 818
 	out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "ls -l /dev/null")
818 819
 	deviceLineFields := strings.Fields(out)
... ...
@@ -827,6 +931,7 @@ func (s *DockerSuite) TestRunDeviceNumbers(c *check.C) {
827 827
 }
828 828
 
829 829
 func (s *DockerSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *check.C) {
830
+	// Not applicable on Windows as /dev/ is a Unix specific concept
830 831
 	testRequires(c, DaemonIsLinux)
831 832
 	out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "dd if=/dev/zero of=/zero bs=1k count=5 2> /dev/null ; du -h /zero")
832 833
 	if actual := strings.Trim(out, "\r\n"); actual[0] == '0' {
... ...
@@ -835,11 +940,13 @@ func (s *DockerSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *chec
835 835
 }
836 836
 
837 837
 func (s *DockerSuite) TestRunUnprivilegedWithChroot(c *check.C) {
838
+	// Not applicable on Windows as it does not support chroot
838 839
 	testRequires(c, DaemonIsLinux)
839 840
 	dockerCmd(c, "run", "busybox", "chroot", "/", "true")
840 841
 }
841 842
 
842 843
 func (s *DockerSuite) TestRunAddingOptionalDevices(c *check.C) {
844
+	// Not applicable on Windows as Windows does not support --device
843 845
 	testRequires(c, DaemonIsLinux)
844 846
 	out, _ := dockerCmd(c, "run", "--device", "/dev/zero:/dev/nulo", "busybox", "sh", "-c", "ls /dev/nulo")
845 847
 	if actual := strings.Trim(out, "\r\n"); actual != "/dev/nulo" {
... ...
@@ -848,6 +955,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevices(c *check.C) {
848 848
 }
849 849
 
850 850
 func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *check.C) {
851
+	// Not applicable on Windows as Windows does not support --device
851 852
 	testRequires(c, DaemonIsLinux)
852 853
 	out, _ := dockerCmd(c, "run", "--device", "/dev/zero:rw", "busybox", "sh", "-c", "ls /dev/zero")
853 854
 	if actual := strings.Trim(out, "\r\n"); actual != "/dev/zero" {
... ...
@@ -856,6 +964,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *check.C) {
856 856
 }
857 857
 
858 858
 func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *check.C) {
859
+	// Not applicable on Windows as Windows does not support --device
859 860
 	testRequires(c, DaemonIsLinux)
860 861
 	_, _, err := dockerCmdWithError("run", "--device", "/dev/zero:ro", "busybox", "sh", "-c", "ls /dev/zero")
861 862
 	if err == nil {
... ...
@@ -864,6 +973,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *check.C) {
864 864
 }
865 865
 
866 866
 func (s *DockerSuite) TestRunModeHostname(c *check.C) {
867
+	// Not applicable on Windows as Windows does not support -h
867 868
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
868 869
 
869 870
 	out, _ := dockerCmd(c, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
... ...
@@ -884,10 +994,13 @@ func (s *DockerSuite) TestRunModeHostname(c *check.C) {
884 884
 }
885 885
 
886 886
 func (s *DockerSuite) TestRunRootWorkdir(c *check.C) {
887
-	testRequires(c, DaemonIsLinux)
888 887
 	out, _ := dockerCmd(c, "run", "--workdir", "/", "busybox", "pwd")
889
-	if out != "/\n" {
890
-		c.Fatalf("pwd returned %q (expected /\\n)", s)
888
+	expected := "/\n"
889
+	if daemonPlatform == "windows" {
890
+		expected = "C:" + expected
891
+	}
892
+	if out != expected {
893
+		c.Fatalf("pwd returned %q (expected %s)", s, expected)
891 894
 	}
892 895
 }
893 896
 
... ...
@@ -897,6 +1010,7 @@ func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) {
897 897
 }
898 898
 
899 899
 func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *check.C) {
900
+	// Not applicable on Windows as Windows does not support volumes
900 901
 	testRequires(c, DaemonIsLinux)
901 902
 	out, _, err := dockerCmdWithError("run", "-v", "/:/", "busybox", "ls", "/host")
902 903
 	if err == nil {
... ...
@@ -906,6 +1020,7 @@ func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *check.C) {
906 906
 
907 907
 // Verify that a container gets default DNS when only localhost resolvers exist
908 908
 func (s *DockerSuite) TestRunDnsDefaultOptions(c *check.C) {
909
+	// Not applicable on Windows as this is testing Unix specific functionality
909 910
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
910 911
 
911 912
 	// preserve original resolv.conf for restoring after test
... ...
@@ -939,6 +1054,8 @@ func (s *DockerSuite) TestRunDnsDefaultOptions(c *check.C) {
939 939
 }
940 940
 
941 941
 func (s *DockerSuite) TestRunDnsOptions(c *check.C) {
942
+	// Not applicable on Windows as Windows does not support --dns*, or
943
+	// the Unix-specific functionality of resolv.conf.
942 944
 	testRequires(c, DaemonIsLinux)
943 945
 	out, stderr, _ := dockerCmdWithStdoutStderr(c, "run", "--dns=127.0.0.1", "--dns-search=mydomain", "--dns-opt=ndots:9", "busybox", "cat", "/etc/resolv.conf")
944 946
 
... ...
@@ -971,6 +1088,7 @@ func (s *DockerSuite) TestRunDnsRepeatOptions(c *check.C) {
971 971
 }
972 972
 
973 973
 func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) {
974
+	// Not applicable on Windows as testing Unix specific functionality
974 975
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
975 976
 
976 977
 	origResolvConf, err := ioutil.ReadFile("/etc/resolv.conf")
... ...
@@ -1053,6 +1171,7 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) {
1053 1053
 // Test to see if a non-root user can resolve a DNS name and reach out to it. Also
1054 1054
 // check if the container resolv.conf file has at least 0644 perm.
1055 1055
 func (s *DockerSuite) TestRunNonRootUserResolvName(c *check.C) {
1056
+	// Not applicable on Windows as Windows does not support --user
1056 1057
 	testRequires(c, SameHostDaemon, Network, DaemonIsLinux)
1057 1058
 
1058 1059
 	dockerCmd(c, "run", "--name=testperm", "--user=default", "busybox", "ping", "-c", "1", "apt.dockerproject.org")
... ...
@@ -1077,6 +1196,7 @@ func (s *DockerSuite) TestRunNonRootUserResolvName(c *check.C) {
1077 1077
 // if host /etc/resolv.conf has changed. This only applies if the container
1078 1078
 // uses the host's /etc/resolv.conf and does not have any dns options provided.
1079 1079
 func (s *DockerSuite) TestRunResolvconfUpdate(c *check.C) {
1080
+	// Not applicable on Windows as testing unix specific functionality
1080 1081
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1081 1082
 
1082 1083
 	tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\n")
... ...
@@ -1256,6 +1376,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *check.C) {
1256 1256
 }
1257 1257
 
1258 1258
 func (s *DockerSuite) TestRunAddHost(c *check.C) {
1259
+	// Not applicable on Windows as it does not support --add-host
1259 1260
 	testRequires(c, DaemonIsLinux)
1260 1261
 	out, _ := dockerCmd(c, "run", "--add-host=extra:86.75.30.9", "busybox", "grep", "extra", "/etc/hosts")
1261 1262
 
... ...
@@ -1267,7 +1388,6 @@ func (s *DockerSuite) TestRunAddHost(c *check.C) {
1267 1267
 
1268 1268
 // Regression test for #6983
1269 1269
 func (s *DockerSuite) TestRunAttachStdErrOnlyTTYMode(c *check.C) {
1270
-	testRequires(c, DaemonIsLinux)
1271 1270
 	_, exitCode := dockerCmd(c, "run", "-t", "-a", "stderr", "busybox", "true")
1272 1271
 	if exitCode != 0 {
1273 1272
 		c.Fatalf("Container should have exited with error code 0")
... ...
@@ -1276,7 +1396,6 @@ func (s *DockerSuite) TestRunAttachStdErrOnlyTTYMode(c *check.C) {
1276 1276
 
1277 1277
 // Regression test for #6983
1278 1278
 func (s *DockerSuite) TestRunAttachStdOutOnlyTTYMode(c *check.C) {
1279
-	testRequires(c, DaemonIsLinux)
1280 1279
 	_, exitCode := dockerCmd(c, "run", "-t", "-a", "stdout", "busybox", "true")
1281 1280
 	if exitCode != 0 {
1282 1281
 		c.Fatalf("Container should have exited with error code 0")
... ...
@@ -1285,7 +1404,6 @@ func (s *DockerSuite) TestRunAttachStdOutOnlyTTYMode(c *check.C) {
1285 1285
 
1286 1286
 // Regression test for #6983
1287 1287
 func (s *DockerSuite) TestRunAttachStdOutAndErrTTYMode(c *check.C) {
1288
-	testRequires(c, DaemonIsLinux)
1289 1288
 	_, exitCode := dockerCmd(c, "run", "-t", "-a", "stdout", "-a", "stderr", "busybox", "true")
1290 1289
 	if exitCode != 0 {
1291 1290
 		c.Fatalf("Container should have exited with error code 0")
... ...
@@ -1295,7 +1413,6 @@ func (s *DockerSuite) TestRunAttachStdOutAndErrTTYMode(c *check.C) {
1295 1295
 // Test for #10388 - this will run the same test as TestRunAttachStdOutAndErrTTYMode
1296 1296
 // but using --attach instead of -a to make sure we read the flag correctly
1297 1297
 func (s *DockerSuite) TestRunAttachWithDetach(c *check.C) {
1298
-	testRequires(c, DaemonIsLinux)
1299 1298
 	cmd := exec.Command(dockerBinary, "run", "-d", "--attach", "stdout", "busybox", "true")
1300 1299
 	_, stderr, _, err := runCommandWithStdoutStderr(cmd)
1301 1300
 	if err == nil {
... ...
@@ -1306,6 +1423,7 @@ func (s *DockerSuite) TestRunAttachWithDetach(c *check.C) {
1306 1306
 }
1307 1307
 
1308 1308
 func (s *DockerSuite) TestRunState(c *check.C) {
1309
+	// TODO Windows: This needs some rework as Windows busybox does not support top
1309 1310
 	testRequires(c, DaemonIsLinux)
1310 1311
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
1311 1312
 
... ...
@@ -1348,6 +1466,7 @@ func (s *DockerSuite) TestRunState(c *check.C) {
1348 1348
 
1349 1349
 // Test for #1737
1350 1350
 func (s *DockerSuite) TestRunCopyVolumeUidGid(c *check.C) {
1351
+	// Not applicable on Windows as it does not support volumes, uid or gid
1351 1352
 	testRequires(c, DaemonIsLinux)
1352 1353
 	name := "testrunvolumesuidgid"
1353 1354
 	_, err := buildImage(name,
... ...
@@ -1370,6 +1489,7 @@ func (s *DockerSuite) TestRunCopyVolumeUidGid(c *check.C) {
1370 1370
 
1371 1371
 // Test for #1582
1372 1372
 func (s *DockerSuite) TestRunCopyVolumeContent(c *check.C) {
1373
+	// Not applicable on Windows as it does not support volumes
1373 1374
 	testRequires(c, DaemonIsLinux)
1374 1375
 	name := "testruncopyvolumecontent"
1375 1376
 	_, err := buildImage(name,
... ...
@@ -1388,7 +1508,6 @@ func (s *DockerSuite) TestRunCopyVolumeContent(c *check.C) {
1388 1388
 }
1389 1389
 
1390 1390
 func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) {
1391
-	testRequires(c, DaemonIsLinux)
1392 1391
 	name := "testrunmdcleanuponentrypoint"
1393 1392
 	if _, err := buildImage(name,
1394 1393
 		`FROM busybox
... ...
@@ -1403,24 +1522,40 @@ func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) {
1403 1403
 		c.Fatalf("expected exit code 0 received %d, out: %q", exit, out)
1404 1404
 	}
1405 1405
 	out = strings.TrimSpace(out)
1406
-	if out != "root" {
1407
-		c.Fatalf("Expected output root, got %q", out)
1406
+	expected := "root"
1407
+	if daemonPlatform == "windows" {
1408
+		expected = `nt authority\system`
1409
+	}
1410
+	if out != expected {
1411
+		c.Fatalf("Expected output %s, got %q", expected, out)
1408 1412
 	}
1409 1413
 }
1410 1414
 
1411 1415
 // TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected
1412 1416
 func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *check.C) {
1413
-	testRequires(c, DaemonIsLinux)
1414
-	out, exit, err := dockerCmdWithError("run", "-w", "/bin/cat", "busybox")
1415
-	if !(err != nil && exit == 1 && strings.Contains(out, "Cannot mkdir: /bin/cat is not a directory")) {
1417
+	existingFile := "/bin/cat"
1418
+	expected := "Cannot mkdir: /bin/cat is not a directory"
1419
+	if daemonPlatform == "windows" {
1420
+		existingFile = `\windows\system32\ntdll.dll`
1421
+		expected = "The directory name is invalid"
1422
+	}
1423
+
1424
+	out, exit, err := dockerCmdWithError("run", "-w", existingFile, "busybox")
1425
+	if !(err != nil && exit == 1 && strings.Contains(out, expected)) {
1416 1426
 		c.Fatalf("Docker must complains about making dir, but we got out: %s, exit: %d, err: %s", out, exit, err)
1417 1427
 	}
1418 1428
 }
1419 1429
 
1420 1430
 func (s *DockerSuite) TestRunExitOnStdinClose(c *check.C) {
1421
-	testRequires(c, DaemonIsLinux)
1422 1431
 	name := "testrunexitonstdinclose"
1423
-	runCmd := exec.Command(dockerBinary, "run", "--name", name, "-i", "busybox", "/bin/cat")
1432
+
1433
+	meow := "/bin/cat"
1434
+	delay := 1
1435
+	if daemonPlatform == "windows" {
1436
+		meow = "cat"
1437
+		delay = 5
1438
+	}
1439
+	runCmd := exec.Command(dockerBinary, "run", "--name", name, "-i", "busybox", meow)
1424 1440
 
1425 1441
 	stdin, err := runCmd.StdinPipe()
1426 1442
 	if err != nil {
... ...
@@ -1458,7 +1593,7 @@ func (s *DockerSuite) TestRunExitOnStdinClose(c *check.C) {
1458 1458
 	select {
1459 1459
 	case err := <-finish:
1460 1460
 		c.Assert(err, check.IsNil)
1461
-	case <-time.After(1 * time.Second):
1461
+	case <-time.After(time.Duration(delay) * time.Second):
1462 1462
 		c.Fatal("docker run failed to exit on stdin close")
1463 1463
 	}
1464 1464
 	state, err := inspectField(name, "State.Running")
... ...
@@ -1471,6 +1606,7 @@ func (s *DockerSuite) TestRunExitOnStdinClose(c *check.C) {
1471 1471
 
1472 1472
 // Test for #2267
1473 1473
 func (s *DockerSuite) TestRunWriteHostsFileAndNotCommit(c *check.C) {
1474
+	// Cannot run on Windows as Windows does not support diff.
1474 1475
 	testRequires(c, DaemonIsLinux)
1475 1476
 	name := "writehosts"
1476 1477
 	out, _ := dockerCmd(c, "run", "--name", name, "busybox", "sh", "-c", "echo test2267 >> /etc/hosts && cat /etc/hosts")
... ...
@@ -1512,6 +1648,7 @@ func sliceEq(a, b []string) bool {
1512 1512
 
1513 1513
 // Test for #2267
1514 1514
 func (s *DockerSuite) TestRunWriteHostnameFileAndNotCommit(c *check.C) {
1515
+	// Cannot run on Windows as Windows does not support diff.
1515 1516
 	testRequires(c, DaemonIsLinux)
1516 1517
 	name := "writehostname"
1517 1518
 	out, _ := dockerCmd(c, "run", "--name", name, "busybox", "sh", "-c", "echo test2267 >> /etc/hostname && cat /etc/hostname")
... ...
@@ -1527,6 +1664,7 @@ func (s *DockerSuite) TestRunWriteHostnameFileAndNotCommit(c *check.C) {
1527 1527
 
1528 1528
 // Test for #2267
1529 1529
 func (s *DockerSuite) TestRunWriteResolvFileAndNotCommit(c *check.C) {
1530
+	// Cannot run on Windows as Windows does not support diff.
1530 1531
 	testRequires(c, DaemonIsLinux)
1531 1532
 	name := "writeresolv"
1532 1533
 	out, _ := dockerCmd(c, "run", "--name", name, "busybox", "sh", "-c", "echo test2267 >> /etc/resolv.conf && cat /etc/resolv.conf")
... ...
@@ -1541,6 +1679,7 @@ func (s *DockerSuite) TestRunWriteResolvFileAndNotCommit(c *check.C) {
1541 1541
 }
1542 1542
 
1543 1543
 func (s *DockerSuite) TestRunWithBadDevice(c *check.C) {
1544
+	// Cannot run on Windows as Windows does not support --device
1544 1545
 	testRequires(c, DaemonIsLinux)
1545 1546
 	name := "baddevice"
1546 1547
 	out, _, err := dockerCmdWithError("run", "--name", name, "--device", "/etc", "busybox", "true")
... ...
@@ -1555,19 +1694,26 @@ func (s *DockerSuite) TestRunWithBadDevice(c *check.C) {
1555 1555
 }
1556 1556
 
1557 1557
 func (s *DockerSuite) TestRunEntrypoint(c *check.C) {
1558
-	testRequires(c, DaemonIsLinux)
1559 1558
 	name := "entrypoint"
1560
-	out, _ := dockerCmd(c, "run", "--name", name, "--entrypoint", "/bin/echo", "busybox", "-n", "foobar")
1561 1559
 
1562
-	expected := "foobar"
1560
+	// Note Windows does not have an echo.exe built in.
1561
+	var out, expected string
1562
+	if daemonPlatform == "windows" {
1563
+		out, _ = dockerCmd(c, "run", "--name", name, "--entrypoint", "cmd /s /c echo", "busybox", "foobar")
1564
+		expected = "foobar\r\n"
1565
+	} else {
1566
+		out, _ = dockerCmd(c, "run", "--name", name, "--entrypoint", "/bin/echo", "busybox", "-n", "foobar")
1567
+		expected = "foobar"
1568
+	}
1569
+
1563 1570
 	if out != expected {
1564 1571
 		c.Fatalf("Output should be %q, actual out: %q", expected, out)
1565 1572
 	}
1566 1573
 }
1567 1574
 
1568 1575
 func (s *DockerSuite) TestRunBindMounts(c *check.C) {
1569
-	testRequires(c, DaemonIsLinux)
1570
-	testRequires(c, SameHostDaemon)
1576
+	// Cannot run on Windows as Windows does not support volumes
1577
+	testRequires(c, DaemonIsLinux, SameHostDaemon)
1571 1578
 
1572 1579
 	tmpDir, err := ioutil.TempDir("", "docker-test-container")
1573 1580
 	if err != nil {
... ...
@@ -1606,7 +1752,6 @@ func (s *DockerSuite) TestRunBindMounts(c *check.C) {
1606 1606
 // Ensure that CIDFile gets deleted if it's empty
1607 1607
 // Perform this test by making `docker run` fail
1608 1608
 func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) {
1609
-	testRequires(c, DaemonIsLinux)
1610 1609
 	tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
1611 1610
 	if err != nil {
1612 1611
 		c.Fatal(err)
... ...
@@ -1614,7 +1759,12 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) {
1614 1614
 	defer os.RemoveAll(tmpDir)
1615 1615
 	tmpCidFile := path.Join(tmpDir, "cid")
1616 1616
 
1617
-	out, _, err := dockerCmdWithError("run", "--cidfile", tmpCidFile, "emptyfs")
1617
+	image := "emptyfs"
1618
+	if daemonPlatform == "windows" {
1619
+		// Windows can't support an emptyfs image. Just use the regular Windows image
1620
+		image = WindowsBaseImage
1621
+	}
1622
+	out, _, err := dockerCmdWithError("run", "--cidfile", tmpCidFile, image)
1618 1623
 	if err == nil {
1619 1624
 		c.Fatalf("Run without command must fail. out=%s", out)
1620 1625
 	} else if !strings.Contains(out, "No command specified") {
... ...
@@ -1630,7 +1780,6 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) {
1630 1630
 //sudo docker run --cidfile /tmp/docker_tesc.cid ubuntu echo "test"
1631 1631
 // TestRunCidFile tests that run --cidfile returns the longid
1632 1632
 func (s *DockerSuite) TestRunCidFileCheckIDLength(c *check.C) {
1633
-	testRequires(c, DaemonIsLinux)
1634 1633
 	tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
1635 1634
 	if err != nil {
1636 1635
 		c.Fatal(err)
... ...
@@ -1655,10 +1804,19 @@ func (s *DockerSuite) TestRunCidFileCheckIDLength(c *check.C) {
1655 1655
 }
1656 1656
 
1657 1657
 func (s *DockerSuite) TestRunSetMacAddress(c *check.C) {
1658
+	// TODO Windows. Test modified to be theoretically Windows compatible,
1659
+	// but the version of busybox being used on Windows doesn't handle
1660
+	// sh -c ipconfig -all (or /all). It ignores the *all bit. This could
1661
+	// be a bug in busybox.
1658 1662
 	testRequires(c, DaemonIsLinux)
1659 1663
 	mac := "12:34:56:78:9a:bc"
1660 1664
 
1661
-	out, _ := dockerCmd(c, "run", "-i", "--rm", fmt.Sprintf("--mac-address=%s", mac), "busybox", "/bin/sh", "-c", "ip link show eth0 | tail -1 | awk '{print $2}'")
1665
+	var out string
1666
+	if daemonPlatform == "windows" {
1667
+		out, _ = dockerCmd(c, "run", "-i", "--rm", fmt.Sprintf("--mac-address=%s", mac), "busybox", "sh", "-c", "ipconfig /all | grep 'Physical Address' | awk '{print $12}'")
1668
+	} else {
1669
+		out, _ = dockerCmd(c, "run", "-i", "--rm", fmt.Sprintf("--mac-address=%s", mac), "busybox", "/bin/sh", "-c", "ip link show eth0 | tail -1 | awk '{print $2}'")
1670
+	}
1662 1671
 
1663 1672
 	actualMac := strings.TrimSpace(out)
1664 1673
 	if actualMac != mac {
... ...
@@ -1667,6 +1825,7 @@ func (s *DockerSuite) TestRunSetMacAddress(c *check.C) {
1667 1667
 }
1668 1668
 
1669 1669
 func (s *DockerSuite) TestRunInspectMacAddress(c *check.C) {
1670
+	// TODO Windows. Network settings are not propagated back to inspect.
1670 1671
 	testRequires(c, DaemonIsLinux)
1671 1672
 	mac := "12:34:56:78:9a:bc"
1672 1673
 	out, _ := dockerCmd(c, "run", "-d", "--mac-address="+mac, "busybox", "top")
... ...
@@ -1681,7 +1840,6 @@ func (s *DockerSuite) TestRunInspectMacAddress(c *check.C) {
1681 1681
 
1682 1682
 // test docker run use a invalid mac address
1683 1683
 func (s *DockerSuite) TestRunWithInvalidMacAddress(c *check.C) {
1684
-	testRequires(c, DaemonIsLinux)
1685 1684
 	out, _, err := dockerCmdWithError("run", "--mac-address", "92:d0:c6:0a:29", "busybox")
1686 1685
 	//use a invalid mac address should with a error out
1687 1686
 	if err == nil || !strings.Contains(out, "is not a valid mac address") {
... ...
@@ -1690,6 +1848,7 @@ func (s *DockerSuite) TestRunWithInvalidMacAddress(c *check.C) {
1690 1690
 }
1691 1691
 
1692 1692
 func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *check.C) {
1693
+	// TODO Windows. Network settings are not propagated back to inspect.
1693 1694
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1694 1695
 
1695 1696
 	out, _ := dockerCmd(c, "run", "-d", "-p", "23:23", "busybox", "top")
... ...
@@ -1711,6 +1870,9 @@ func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *check.C) {
1711 1711
 }
1712 1712
 
1713 1713
 func (s *DockerSuite) TestRunPortInUse(c *check.C) {
1714
+	// TODO Windows. The duplicate NAT message returned by Windows will be
1715
+	// changing as is currently completely undecipherable. Does need modifying
1716
+	// to run sh rather than top though as top isn't in Windows busybox.
1714 1717
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1715 1718
 
1716 1719
 	port := "1234"
... ...
@@ -1727,6 +1889,7 @@ func (s *DockerSuite) TestRunPortInUse(c *check.C) {
1727 1727
 
1728 1728
 // https://github.com/docker/docker/issues/12148
1729 1729
 func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *check.C) {
1730
+	// TODO Windows. -P is not yet supported
1730 1731
 	testRequires(c, DaemonIsLinux)
1731 1732
 	// allocate a dynamic port to get the most recent
1732 1733
 	out, _ := dockerCmd(c, "run", "-d", "-P", "-p", "80", "busybox", "top")
... ...
@@ -1747,6 +1910,7 @@ func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *check.C) {
1747 1747
 
1748 1748
 // Regression test for #7792
1749 1749
 func (s *DockerSuite) TestRunMountOrdering(c *check.C) {
1750
+	// Not applicable on Windows as Windows does not support volumes
1750 1751
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1751 1752
 
1752 1753
 	tmpDir, err := ioutil.TempDir("", "docker_nested_mount_test")
... ...
@@ -1790,6 +1954,7 @@ func (s *DockerSuite) TestRunMountOrdering(c *check.C) {
1790 1790
 
1791 1791
 // Regression test for https://github.com/docker/docker/issues/8259
1792 1792
 func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *check.C) {
1793
+	// Not applicable on Windows as Windows does not support volumes
1793 1794
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1794 1795
 
1795 1796
 	tmpDir, err := ioutil.TempDir(os.TempDir(), "testlink")
... ...
@@ -1814,6 +1979,7 @@ func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *check.C) {
1814 1814
 
1815 1815
 //GH#10604: Test an "/etc" volume doesn't overlay special bind mounts in container
1816 1816
 func (s *DockerSuite) TestRunCreateVolumeEtc(c *check.C) {
1817
+	// Not applicable on Windows as Windows does not support volumes
1817 1818
 	testRequires(c, DaemonIsLinux)
1818 1819
 	out, _ := dockerCmd(c, "run", "--dns=127.0.0.1", "-v", "/etc", "busybox", "cat", "/etc/resolv.conf")
1819 1820
 	if !strings.Contains(out, "nameserver 127.0.0.1") {
... ...
@@ -1833,6 +1999,7 @@ func (s *DockerSuite) TestRunCreateVolumeEtc(c *check.C) {
1833 1833
 }
1834 1834
 
1835 1835
 func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) {
1836
+	// Not applicable on Windows as Windows does not support volumes
1836 1837
 	testRequires(c, DaemonIsLinux)
1837 1838
 	if _, err := buildImage("dataimage",
1838 1839
 		`FROM busybox
... ...
@@ -1868,6 +2035,7 @@ func (s *DockerSuite) TestRunNoOutputFromPullInStdout(c *check.C) {
1868 1868
 }
1869 1869
 
1870 1870
 func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) {
1871
+	// Not applicable on Windows as Windows does not support volumes
1871 1872
 	testRequires(c, DaemonIsLinux)
1872 1873
 	if _, err := buildImage("run_volumes_clean_paths",
1873 1874
 		`FROM busybox
... ...
@@ -1903,6 +2071,8 @@ func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) {
1903 1903
 
1904 1904
 // Regression test for #3631
1905 1905
 func (s *DockerSuite) TestRunSlowStdoutConsumer(c *check.C) {
1906
+	// TODO Windows: This should be able to run on Windows if can find an
1907
+	// alternate to /dev/zero and /dev/stdout.
1906 1908
 	testRequires(c, DaemonIsLinux)
1907 1909
 	cont := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "dd if=/dev/zero of=/dev/stdout bs=1024 count=2000 | catv")
1908 1910
 
... ...
@@ -1926,6 +2096,8 @@ func (s *DockerSuite) TestRunSlowStdoutConsumer(c *check.C) {
1926 1926
 }
1927 1927
 
1928 1928
 func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *check.C) {
1929
+	// TODO Windows: -P is not currently supported. Also network
1930
+	// settings are not propagated back.
1929 1931
 	testRequires(c, DaemonIsLinux)
1930 1932
 	out, _ := dockerCmd(c, "run", "-d", "--expose", "3000-3003", "-P", "busybox", "top")
1931 1933
 
... ...
@@ -1949,7 +2121,6 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *check.C) {
1949 1949
 
1950 1950
 // test docker run expose a invalid port
1951 1951
 func (s *DockerSuite) TestRunExposePort(c *check.C) {
1952
-	testRequires(c, DaemonIsLinux)
1953 1952
 	out, _, err := dockerCmdWithError("run", "--expose", "80000", "busybox")
1954 1953
 	//expose a invalid port should with a error out
1955 1954
 	if err == nil || !strings.Contains(out, "Invalid range format for --expose") {
... ...
@@ -1958,12 +2129,25 @@ func (s *DockerSuite) TestRunExposePort(c *check.C) {
1958 1958
 }
1959 1959
 
1960 1960
 func (s *DockerSuite) TestRunUnknownCommand(c *check.C) {
1961
-	testRequires(c, NativeExecDriver, DaemonIsLinux)
1961
+	if daemonPlatform != "windows" {
1962
+		testRequires(c, NativeExecDriver)
1963
+	}
1962 1964
 	out, _, _ := dockerCmdWithStdoutStderr(c, "create", "busybox", "/bin/nada")
1963 1965
 
1964 1966
 	cID := strings.TrimSpace(out)
1965 1967
 	_, _, err := dockerCmdWithError("start", cID)
1966
-	c.Assert(err, check.NotNil)
1968
+
1969
+	// Windows and Linux are different here by architectural design. Linux will
1970
+	// fail to start the container, so an error is expected. Windows will
1971
+	// successfully start the container, and once started attempt to execute
1972
+	// the command which will fail.
1973
+	if daemonPlatform == "windows" {
1974
+		// Wait for it to exit.
1975
+		waitExited(cID, 30)
1976
+		c.Assert(err, check.IsNil)
1977
+	} else {
1978
+		c.Assert(err, check.NotNil)
1979
+	}
1967 1980
 
1968 1981
 	rc, err := inspectField(cID, "State.ExitCode")
1969 1982
 	c.Assert(err, check.IsNil)
... ...
@@ -1973,6 +2157,7 @@ func (s *DockerSuite) TestRunUnknownCommand(c *check.C) {
1973 1973
 }
1974 1974
 
1975 1975
 func (s *DockerSuite) TestRunModeIpcHost(c *check.C) {
1976
+	// Not applicable on Windows as uses Unix-specific capabilities
1976 1977
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1977 1978
 
1978 1979
 	hostIpc, err := os.Readlink("/proc/1/ns/ipc")
... ...
@@ -1994,6 +2179,7 @@ func (s *DockerSuite) TestRunModeIpcHost(c *check.C) {
1994 1994
 }
1995 1995
 
1996 1996
 func (s *DockerSuite) TestRunModeIpcContainer(c *check.C) {
1997
+	// Not applicable on Windows as uses Unix-specific capabilities
1997 1998
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1998 1999
 
1999 2000
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
... ...
@@ -2020,6 +2206,7 @@ func (s *DockerSuite) TestRunModeIpcContainer(c *check.C) {
2020 2020
 }
2021 2021
 
2022 2022
 func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *check.C) {
2023
+	// Not applicable on Windows as uses Unix-specific capabilities
2023 2024
 	testRequires(c, DaemonIsLinux)
2024 2025
 	out, _, err := dockerCmdWithError("run", "-d", "--ipc", "container:abcd1234", "busybox", "top")
2025 2026
 	if !strings.Contains(out, "abcd1234") || err == nil {
... ...
@@ -2028,6 +2215,7 @@ func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *check.C) {
2028 2028
 }
2029 2029
 
2030 2030
 func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *check.C) {
2031
+	// Not applicable on Windows as uses Unix-specific capabilities
2031 2032
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2032 2033
 
2033 2034
 	out, _ := dockerCmd(c, "create", "busybox")
... ...
@@ -2040,6 +2228,7 @@ func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *check.C) {
2040 2040
 }
2041 2041
 
2042 2042
 func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
2043
+	// Not applicable on Windows as uses Unix-specific capabilities
2043 2044
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2044 2045
 
2045 2046
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
... ...
@@ -2061,6 +2250,7 @@ func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
2061 2061
 }
2062 2062
 
2063 2063
 func (s *DockerSuite) TestRunModePidHost(c *check.C) {
2064
+	// Not applicable on Windows as uses Unix-specific capabilities
2064 2065
 	testRequires(c, NativeExecDriver, SameHostDaemon, DaemonIsLinux)
2065 2066
 
2066 2067
 	hostPid, err := os.Readlink("/proc/1/ns/pid")
... ...
@@ -2082,6 +2272,7 @@ func (s *DockerSuite) TestRunModePidHost(c *check.C) {
2082 2082
 }
2083 2083
 
2084 2084
 func (s *DockerSuite) TestRunModeUTSHost(c *check.C) {
2085
+	// Not applicable on Windows as uses Unix-specific capabilities
2085 2086
 	testRequires(c, NativeExecDriver, SameHostDaemon, DaemonIsLinux)
2086 2087
 
2087 2088
 	hostUTS, err := os.Readlink("/proc/1/ns/uts")
... ...
@@ -2103,7 +2294,6 @@ func (s *DockerSuite) TestRunModeUTSHost(c *check.C) {
2103 2103
 }
2104 2104
 
2105 2105
 func (s *DockerSuite) TestRunTLSverify(c *check.C) {
2106
-	testRequires(c, DaemonIsLinux)
2107 2106
 	if out, code, err := dockerCmdWithError("ps"); err != nil || code != 0 {
2108 2107
 		c.Fatalf("Should have worked: %v:\n%v", err, out)
2109 2108
 	}
... ...
@@ -2122,6 +2312,8 @@ func (s *DockerSuite) TestRunTLSverify(c *check.C) {
2122 2122
 }
2123 2123
 
2124 2124
 func (s *DockerSuite) TestRunPortFromDockerRangeInUse(c *check.C) {
2125
+	// TODO Windows. Once moved to libnetwork/CNM, this may be able to be
2126
+	// re-instated.
2125 2127
 	testRequires(c, DaemonIsLinux)
2126 2128
 	// first find allocator current position
2127 2129
 	out, _ := dockerCmd(c, "run", "-d", "-p", ":80", "busybox", "top")
... ...
@@ -2152,7 +2344,6 @@ func (s *DockerSuite) TestRunPortFromDockerRangeInUse(c *check.C) {
2152 2152
 }
2153 2153
 
2154 2154
 func (s *DockerSuite) TestRunTtyWithPipe(c *check.C) {
2155
-	testRequires(c, DaemonIsLinux)
2156 2155
 	errChan := make(chan error)
2157 2156
 	go func() {
2158 2157
 		defer close(errChan)
... ...
@@ -2176,21 +2367,31 @@ func (s *DockerSuite) TestRunTtyWithPipe(c *check.C) {
2176 2176
 	select {
2177 2177
 	case err := <-errChan:
2178 2178
 		c.Assert(err, check.IsNil)
2179
-	case <-time.After(3 * time.Second):
2179
+	case <-time.After(6 * time.Second):
2180 2180
 		c.Fatal("container is running but should have failed")
2181 2181
 	}
2182 2182
 }
2183 2183
 
2184 2184
 func (s *DockerSuite) TestRunNonLocalMacAddress(c *check.C) {
2185
-	testRequires(c, DaemonIsLinux)
2186 2185
 	addr := "00:16:3E:08:00:50"
2186
+	cmd := "ifconfig"
2187
+	image := "busybox"
2188
+	expected := addr
2189
+
2190
+	if daemonPlatform == "windows" {
2191
+		cmd = "ipconfig /all"
2192
+		image = WindowsBaseImage
2193
+		expected = strings.Replace(addr, ":", "-", -1)
2187 2194
 
2188
-	if out, _ := dockerCmd(c, "run", "--mac-address", addr, "busybox", "ifconfig"); !strings.Contains(out, addr) {
2189
-		c.Fatalf("Output should have contained %q: %s", addr, out)
2195
+	}
2196
+
2197
+	if out, _ := dockerCmd(c, "run", "--mac-address", addr, image, cmd); !strings.Contains(out, expected) {
2198
+		c.Fatalf("Output should have contained %q: %s", expected, out)
2190 2199
 	}
2191 2200
 }
2192 2201
 
2193 2202
 func (s *DockerSuite) TestRunNetHost(c *check.C) {
2203
+	// Not applicable on Windows as uses Unix-specific capabilities
2194 2204
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2195 2205
 
2196 2206
 	hostNet, err := os.Readlink("/proc/1/ns/net")
... ...
@@ -2212,6 +2413,8 @@ func (s *DockerSuite) TestRunNetHost(c *check.C) {
2212 2212
 }
2213 2213
 
2214 2214
 func (s *DockerSuite) TestRunNetHostTwiceSameName(c *check.C) {
2215
+	// TODO Windows. As Windows networking evolves and converges towards
2216
+	// CNM, this test may be possible to enable on Windows.
2215 2217
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2216 2218
 
2217 2219
 	dockerCmd(c, "run", "--rm", "--name=thost", "--net=host", "busybox", "true")
... ...
@@ -2219,6 +2422,7 @@ func (s *DockerSuite) TestRunNetHostTwiceSameName(c *check.C) {
2219 2219
 }
2220 2220
 
2221 2221
 func (s *DockerSuite) TestRunNetContainerWhichHost(c *check.C) {
2222
+	// Not applicable on Windows as uses Unix-specific capabilities
2222 2223
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2223 2224
 
2224 2225
 	hostNet, err := os.Readlink("/proc/1/ns/net")
... ...
@@ -2236,6 +2440,9 @@ func (s *DockerSuite) TestRunNetContainerWhichHost(c *check.C) {
2236 2236
 }
2237 2237
 
2238 2238
 func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) {
2239
+	// TODO Windows. This may be possible to enable in the future. However,
2240
+	// Windows does not currently support --expose, or populate the network
2241
+	// settings seen through inspect.
2239 2242
 	testRequires(c, DaemonIsLinux)
2240 2243
 	out, _ := dockerCmd(c, "run", "-d", "--expose", "3000-3003", "-p", "3000-3003", "busybox", "top")
2241 2244
 
... ...
@@ -2257,9 +2464,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) {
2257 2257
 }
2258 2258
 
2259 2259
 func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *check.C) {
2260
-	testRequires(c, DaemonIsLinux)
2261
-	dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
2262
-
2260
+	dockerCmd(c, "run", "-d", "--name", "test", "busybox", "sleep", "30")
2263 2261
 	out, err := inspectField("test", "HostConfig.RestartPolicy.Name")
2264 2262
 	c.Assert(err, check.IsNil)
2265 2263
 	if out != "no" {
... ...
@@ -2268,11 +2473,14 @@ func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *check.C) {
2268 2268
 }
2269 2269
 
2270 2270
 func (s *DockerSuite) TestRunRestartMaxRetries(c *check.C) {
2271
-	testRequires(c, DaemonIsLinux)
2272 2271
 	out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false")
2272
+	timeout := 10 * time.Second
2273
+	if daemonPlatform == "windows" {
2274
+		timeout = 45 * time.Second
2275
+	}
2273 2276
 
2274 2277
 	id := strings.TrimSpace(string(out))
2275
-	if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 10); err != nil {
2278
+	if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", timeout); err != nil {
2276 2279
 		c.Fatal(err)
2277 2280
 	}
2278 2281
 
... ...
@@ -2290,11 +2498,11 @@ func (s *DockerSuite) TestRunRestartMaxRetries(c *check.C) {
2290 2290
 }
2291 2291
 
2292 2292
 func (s *DockerSuite) TestRunContainerWithWritableRootfs(c *check.C) {
2293
-	testRequires(c, DaemonIsLinux)
2294 2293
 	dockerCmd(c, "run", "--rm", "busybox", "touch", "/file")
2295 2294
 }
2296 2295
 
2297 2296
 func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
2297
+	// Not applicable on Windows which does not support --read-only
2298 2298
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2299 2299
 
2300 2300
 	for _, f := range []string{"/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname", "/sys/kernel", "/dev/.dont.touch.me"} {
... ...
@@ -2303,8 +2511,9 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
2303 2303
 }
2304 2304
 
2305 2305
 func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
2306
-	testRequires(c, DaemonIsLinux)
2307
-	testRequires(c, NativeExecDriver)
2306
+	// Not applicable on Windows due to use of Unix specific functionality, plus
2307
+	// the use of --read-only which is not supported.
2308
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2308 2309
 
2309 2310
 	// Ensure we have not broken writing /dev/pts
2310 2311
 	out, status := dockerCmd(c, "run", "--read-only", "--rm", "busybox", "mount")
... ...
@@ -2318,6 +2527,7 @@ func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
2318 2318
 }
2319 2319
 
2320 2320
 func testReadOnlyFile(filename string, c *check.C) {
2321
+	// Not applicable on Windows which does not support --read-only
2321 2322
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2322 2323
 
2323 2324
 	out, _, err := dockerCmdWithError("run", "--read-only", "--rm", "busybox", "touch", filename)
... ...
@@ -2340,6 +2550,7 @@ func testReadOnlyFile(filename string, c *check.C) {
2340 2340
 }
2341 2341
 
2342 2342
 func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *check.C) {
2343
+	// Not applicable on Windows which does not support --link
2343 2344
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2344 2345
 
2345 2346
 	dockerCmd(c, "run", "-d", "--name", "test-etc-hosts-ro-linked", "busybox", "top")
... ...
@@ -2351,6 +2562,8 @@ func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *
2351 2351
 }
2352 2352
 
2353 2353
 func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDnsFlag(c *check.C) {
2354
+	// Not applicable on Windows which does not support either --read-only or
2355
+	// --dns.
2354 2356
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2355 2357
 
2356 2358
 	out, _ := dockerCmd(c, "run", "--read-only", "--dns", "1.1.1.1", "busybox", "/bin/cat", "/etc/resolv.conf")
... ...
@@ -2360,6 +2573,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDnsFlag(c *check.C)
2360 2360
 }
2361 2361
 
2362 2362
 func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *check.C) {
2363
+	// Not applicable on Windows which does not support --read-only
2363 2364
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2364 2365
 
2365 2366
 	out, _ := dockerCmd(c, "run", "--read-only", "--add-host", "testreadonly:127.0.0.1", "busybox", "/bin/cat", "/etc/hosts")
... ...
@@ -2369,6 +2583,8 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *check
2369 2369
 }
2370 2370
 
2371 2371
 func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *check.C) {
2372
+	// TODO Windows. Not applicable on Windows which does not support volumes.
2373
+	// This may be possible to add in the future.
2372 2374
 	testRequires(c, DaemonIsLinux)
2373 2375
 	dockerCmd(c, "run", "-d", "--name", "voltest", "-v", "/foo", "busybox")
2374 2376
 	dockerCmd(c, "run", "-d", "--name", "restarter", "--volumes-from", "voltest", "busybox", "top")
... ...
@@ -2382,7 +2598,6 @@ func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *check.C) {
2382 2382
 
2383 2383
 // run container with --rm should remove container if exit code != 0
2384 2384
 func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *check.C) {
2385
-	testRequires(c, DaemonIsLinux)
2386 2385
 	name := "flowers"
2387 2386
 	out, _, err := dockerCmdWithError("run", "--name", name, "--rm", "busybox", "ls", "/notexists")
2388 2387
 	if err == nil {
... ...
@@ -2400,7 +2615,6 @@ func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *check.
2400 2400
 }
2401 2401
 
2402 2402
 func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *check.C) {
2403
-	testRequires(c, DaemonIsLinux)
2404 2403
 	name := "sparkles"
2405 2404
 	out, _, err := dockerCmdWithError("run", "--name", name, "--rm", "busybox", "commandNotFound")
2406 2405
 	if err == nil {
... ...
@@ -2418,6 +2632,7 @@ func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *check.C)
2418 2418
 }
2419 2419
 
2420 2420
 func (s *DockerSuite) TestRunPidHostWithChildIsKillable(c *check.C) {
2421
+	// Not applicable on Windows as uses Unix specific functionality
2421 2422
 	testRequires(c, DaemonIsLinux)
2422 2423
 	name := "ibuildthecloud"
2423 2424
 	dockerCmd(c, "run", "-d", "--pid=host", "--name", name, "busybox", "sh", "-c", "sleep 30; echo hi")
... ...
@@ -2440,6 +2655,8 @@ func (s *DockerSuite) TestRunPidHostWithChildIsKillable(c *check.C) {
2440 2440
 }
2441 2441
 
2442 2442
 func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *check.C) {
2443
+	// TODO Windows. This may be possible to enable once Windows supports
2444
+	// memory limits on containers
2443 2445
 	testRequires(c, DaemonIsLinux)
2444 2446
 	// this memory limit is 1 byte less than the min, which is 4MB
2445 2447
 	// https://github.com/docker/docker/blob/v1.5.0/daemon/create.go#L22
... ...
@@ -2450,6 +2667,7 @@ func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *check.C) {
2450 2450
 }
2451 2451
 
2452 2452
 func (s *DockerSuite) TestRunWriteToProcAsound(c *check.C) {
2453
+	// Not applicable on Windows as uses Unix specific functionality
2453 2454
 	testRequires(c, DaemonIsLinux)
2454 2455
 	_, code, err := dockerCmdWithError("run", "busybox", "sh", "-c", "echo 111 >> /proc/asound/version")
2455 2456
 	if err == nil || code == 0 {
... ...
@@ -2458,6 +2676,7 @@ func (s *DockerSuite) TestRunWriteToProcAsound(c *check.C) {
2458 2458
 }
2459 2459
 
2460 2460
 func (s *DockerSuite) TestRunReadProcTimer(c *check.C) {
2461
+	// Not applicable on Windows as uses Unix specific functionality
2461 2462
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2462 2463
 	out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/timer_stats")
2463 2464
 	if code != 0 {
... ...
@@ -2472,6 +2691,7 @@ func (s *DockerSuite) TestRunReadProcTimer(c *check.C) {
2472 2472
 }
2473 2473
 
2474 2474
 func (s *DockerSuite) TestRunReadProcLatency(c *check.C) {
2475
+	// Not applicable on Windows as uses Unix specific functionality
2475 2476
 	testRequires(c, NativeExecDriver, DaemonIsLinux)
2476 2477
 	// some kernels don't have this configured so skip the test if this file is not found
2477 2478
 	// on the host running the tests.
... ...
@@ -2492,6 +2712,7 @@ func (s *DockerSuite) TestRunReadProcLatency(c *check.C) {
2492 2492
 }
2493 2493
 
2494 2494
 func (s *DockerSuite) TestRunReadFilteredProc(c *check.C) {
2495
+	// Not applicable on Windows as uses Unix specific functionality
2495 2496
 	testRequires(c, Apparmor, DaemonIsLinux)
2496 2497
 
2497 2498
 	testReadPaths := []string{
... ...
@@ -2514,6 +2735,7 @@ func (s *DockerSuite) TestRunReadFilteredProc(c *check.C) {
2514 2514
 }
2515 2515
 
2516 2516
 func (s *DockerSuite) TestMountIntoProc(c *check.C) {
2517
+	// Not applicable on Windows as uses Unix specific functionality
2517 2518
 	testRequires(c, DaemonIsLinux)
2518 2519
 	testRequires(c, NativeExecDriver)
2519 2520
 	_, code, err := dockerCmdWithError("run", "-v", "/proc//sys", "busybox", "true")
... ...
@@ -2523,12 +2745,13 @@ func (s *DockerSuite) TestMountIntoProc(c *check.C) {
2523 2523
 }
2524 2524
 
2525 2525
 func (s *DockerSuite) TestMountIntoSys(c *check.C) {
2526
-	testRequires(c, DaemonIsLinux)
2527
-	testRequires(c, NativeExecDriver)
2526
+	// Not applicable on Windows as uses Unix specific functionality
2527
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2528 2528
 	dockerCmd(c, "run", "-v", "/sys/fs/cgroup", "busybox", "true")
2529 2529
 }
2530 2530
 
2531 2531
 func (s *DockerSuite) TestRunUnshareProc(c *check.C) {
2532
+	// Not applicable on Windows as uses Unix specific functionality
2532 2533
 	testRequires(c, Apparmor, NativeExecDriver, DaemonIsLinux)
2533 2534
 
2534 2535
 	name := "acidburn"
... ...
@@ -2549,6 +2772,7 @@ func (s *DockerSuite) TestRunUnshareProc(c *check.C) {
2549 2549
 }
2550 2550
 
2551 2551
 func (s *DockerSuite) TestRunPublishPort(c *check.C) {
2552
+	// TODO Windows: This may be possible once Windows moves to libnetwork and CNM
2552 2553
 	testRequires(c, DaemonIsLinux)
2553 2554
 	dockerCmd(c, "run", "-d", "--name", "test", "--expose", "8080", "busybox", "top")
2554 2555
 	out, _ := dockerCmd(c, "port", "test")
... ...
@@ -2560,6 +2784,7 @@ func (s *DockerSuite) TestRunPublishPort(c *check.C) {
2560 2560
 
2561 2561
 // Issue #10184.
2562 2562
 func (s *DockerSuite) TestDevicePermissions(c *check.C) {
2563
+	// Not applicable on Windows as uses Unix specific functionality
2563 2564
 	testRequires(c, DaemonIsLinux)
2564 2565
 	testRequires(c, NativeExecDriver)
2565 2566
 	const permissions = "crw-rw-rw-"
... ...
@@ -2573,6 +2798,7 @@ func (s *DockerSuite) TestDevicePermissions(c *check.C) {
2573 2573
 }
2574 2574
 
2575 2575
 func (s *DockerSuite) TestRunCapAddCHOWN(c *check.C) {
2576
+	// Not applicable on Windows as uses Unix specific functionality
2576 2577
 	testRequires(c, DaemonIsLinux)
2577 2578
 	testRequires(c, NativeExecDriver)
2578 2579
 	out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=CHOWN", "busybox", "sh", "-c", "adduser -D -H newuser && chown newuser /home && echo ok")
... ...
@@ -2584,6 +2810,7 @@ func (s *DockerSuite) TestRunCapAddCHOWN(c *check.C) {
2584 2584
 
2585 2585
 // https://github.com/docker/docker/pull/14498
2586 2586
 func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) {
2587
+	// Not applicable on Windows as volumes are not supported on Winodws
2587 2588
 	testRequires(c, DaemonIsLinux)
2588 2589
 	dockerCmd(c, "run", "--name", "parent", "-v", "/test", "busybox", "true")
2589 2590
 	dockerCmd(c, "run", "--volumes-from", "parent:ro", "--name", "test-volumes-1", "busybox", "true")
... ...
@@ -2603,6 +2830,7 @@ func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) {
2603 2603
 }
2604 2604
 
2605 2605
 func (s *DockerSuite) TestRunWriteFilteredProc(c *check.C) {
2606
+	// Not applicable on Windows as uses Unix specific functionality
2606 2607
 	testRequires(c, Apparmor, NativeExecDriver, DaemonIsLinux)
2607 2608
 
2608 2609
 	testWritePaths := []string{
... ...
@@ -2629,6 +2857,7 @@ func (s *DockerSuite) TestRunWriteFilteredProc(c *check.C) {
2629 2629
 }
2630 2630
 
2631 2631
 func (s *DockerSuite) TestRunNetworkFilesBindMount(c *check.C) {
2632
+	// Not applicable on Windows as uses Unix specific functionality
2632 2633
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2633 2634
 
2634 2635
 	expected := "test123"
... ...
@@ -2647,6 +2876,7 @@ func (s *DockerSuite) TestRunNetworkFilesBindMount(c *check.C) {
2647 2647
 }
2648 2648
 
2649 2649
 func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *check.C) {
2650
+	// Not applicable on Windows as uses Unix specific functionality
2650 2651
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2651 2652
 
2652 2653
 	filename := createTmpFile(c, "test123")
... ...
@@ -2663,6 +2893,7 @@ func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *check.C) {
2663 2663
 }
2664 2664
 
2665 2665
 func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *check.C) {
2666
+	// Not applicable on Windows as uses Unix specific functionality
2666 2667
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
2667 2668
 
2668 2669
 	filename := createTmpFile(c, "test123")
... ...
@@ -2686,6 +2917,7 @@ func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *check.C) {
2686 2686
 }
2687 2687
 
2688 2688
 func (s *DockerTrustSuite) TestTrustedRun(c *check.C) {
2689
+	// Windows does not support this functionality
2689 2690
 	testRequires(c, DaemonIsLinux)
2690 2691
 	repoName := s.setupTrustedImage(c, "trusted-run")
2691 2692
 
... ...
@@ -2717,6 +2949,7 @@ func (s *DockerTrustSuite) TestTrustedRun(c *check.C) {
2717 2717
 }
2718 2718
 
2719 2719
 func (s *DockerTrustSuite) TestUntrustedRun(c *check.C) {
2720
+	// Windows does not support this functionality
2720 2721
 	testRequires(c, DaemonIsLinux)
2721 2722
 	repoName := fmt.Sprintf("%v/dockercli/trusted:latest", privateRegistryURL)
2722 2723
 	// tag the image and upload it to the private registry
... ...
@@ -2738,6 +2971,7 @@ func (s *DockerTrustSuite) TestUntrustedRun(c *check.C) {
2738 2738
 }
2739 2739
 
2740 2740
 func (s *DockerTrustSuite) TestRunWhenCertExpired(c *check.C) {
2741
+	// Windows does not support this functionality
2741 2742
 	testRequires(c, DaemonIsLinux)
2742 2743
 	c.Skip("Currently changes system time, causing instability")
2743 2744
 	repoName := s.setupTrustedImage(c, "trusted-run-expired")
... ...
@@ -2775,6 +3009,7 @@ func (s *DockerTrustSuite) TestRunWhenCertExpired(c *check.C) {
2775 2775
 }
2776 2776
 
2777 2777
 func (s *DockerTrustSuite) TestTrustedRunFromBadTrustServer(c *check.C) {
2778
+	// Windows does not support this functionality
2778 2779
 	testRequires(c, DaemonIsLinux)
2779 2780
 	repoName := fmt.Sprintf("%v/dockerclievilrun/trusted:latest", privateRegistryURL)
2780 2781
 	evilLocalConfigDir, err := ioutil.TempDir("", "evil-local-config-dir")
... ...
@@ -2847,8 +3082,8 @@ func (s *DockerTrustSuite) TestTrustedRunFromBadTrustServer(c *check.C) {
2847 2847
 }
2848 2848
 
2849 2849
 func (s *DockerSuite) TestPtraceContainerProcsFromHost(c *check.C) {
2850
-	testRequires(c, DaemonIsLinux)
2851
-	testRequires(c, SameHostDaemon)
2850
+	// Not applicable on Windows as uses Unix specific functionality
2851
+	testRequires(c, DaemonIsLinux, SameHostDaemon)
2852 2852
 
2853 2853
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
2854 2854
 	id := strings.TrimSpace(out)
... ...
@@ -2863,6 +3098,7 @@ func (s *DockerSuite) TestPtraceContainerProcsFromHost(c *check.C) {
2863 2863
 }
2864 2864
 
2865 2865
 func (s *DockerSuite) TestAppArmorDeniesPtrace(c *check.C) {
2866
+	// Not applicable on Windows as uses Unix specific functionality
2866 2867
 	testRequires(c, SameHostDaemon, NativeExecDriver, Apparmor, DaemonIsLinux, NotGCCGO)
2867 2868
 
2868 2869
 	// Run through 'sh' so we are NOT pid 1. Pid 1 may be able to trace
... ...
@@ -2874,9 +3110,8 @@ func (s *DockerSuite) TestAppArmorDeniesPtrace(c *check.C) {
2874 2874
 }
2875 2875
 
2876 2876
 func (s *DockerSuite) TestAppArmorTraceSelf(c *check.C) {
2877
-	testRequires(c, DaemonIsLinux)
2878
-	testRequires(c, SameHostDaemon)
2879
-	testRequires(c, Apparmor)
2877
+	// Not applicable on Windows as uses Unix specific functionality
2878
+	testRequires(c, DaemonIsLinux, SameHostDaemon, Apparmor)
2880 2879
 
2881 2880
 	_, exitCode, _ := dockerCmdWithError("run", "busybox", "readlink", "/proc/1/ns/net")
2882 2881
 	if exitCode != 0 {
... ...
@@ -2885,6 +3120,7 @@ func (s *DockerSuite) TestAppArmorTraceSelf(c *check.C) {
2885 2885
 }
2886 2886
 
2887 2887
 func (s *DockerSuite) TestAppArmorDeniesChmodProc(c *check.C) {
2888
+	// Not applicable on Windows as uses Unix specific functionality
2888 2889
 	testRequires(c, SameHostDaemon, NativeExecDriver, Apparmor, DaemonIsLinux)
2889 2890
 	_, exitCode, _ := dockerCmdWithError("run", "busybox", "chmod", "744", "/proc/cpuinfo")
2890 2891
 	if exitCode == 0 {
... ...
@@ -2897,14 +3133,15 @@ func (s *DockerSuite) TestAppArmorDeniesChmodProc(c *check.C) {
2897 2897
 }
2898 2898
 
2899 2899
 func (s *DockerSuite) TestRunCapAddSYSTIME(c *check.C) {
2900
-	testRequires(c, DaemonIsLinux)
2901
-	testRequires(c, NativeExecDriver)
2900
+	// Not applicable on Windows as uses Unix specific functionality
2901
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2902 2902
 
2903 2903
 	dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=SYS_TIME", "busybox", "sh", "-c", "grep ^CapEff /proc/self/status | sed 's/^CapEff:\t//' | grep ^0000000002000000$")
2904 2904
 }
2905 2905
 
2906 2906
 // run create container failed should clean up the container
2907 2907
 func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *check.C) {
2908
+	// TODO Windows. This may be possible to enable once link is supported
2908 2909
 	testRequires(c, DaemonIsLinux)
2909 2910
 	name := "unique_name"
2910 2911
 	_, _, err := dockerCmdWithError("run", "--name", name, "--link", "nothing:nothing", "busybox")
... ...
@@ -2915,6 +3152,7 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *check.C) {
2915 2915
 }
2916 2916
 
2917 2917
 func (s *DockerSuite) TestRunNamedVolume(c *check.C) {
2918
+	// TODO Windows: This may be possible to modify once Windows supports volumes
2918 2919
 	testRequires(c, DaemonIsLinux)
2919 2920
 	dockerCmd(c, "run", "--name=test", "-v", "testing:/foo", "busybox", "sh", "-c", "echo hello > /foo/bar")
2920 2921
 
... ...
@@ -2926,7 +3164,8 @@ func (s *DockerSuite) TestRunNamedVolume(c *check.C) {
2926 2926
 }
2927 2927
 
2928 2928
 func (s *DockerSuite) TestRunWithUlimits(c *check.C) {
2929
-	testRequires(c, NativeExecDriver)
2929
+	// Not applicable on Windows as uses Unix specific functionality
2930
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2930 2931
 
2931 2932
 	out, _ := dockerCmd(c, "run", "--name=testulimits", "--ulimit", "nofile=42", "busybox", "/bin/sh", "-c", "ulimit -n")
2932 2933
 	ul := strings.TrimSpace(out)
... ...
@@ -2936,7 +3175,8 @@ func (s *DockerSuite) TestRunWithUlimits(c *check.C) {
2936 2936
 }
2937 2937
 
2938 2938
 func (s *DockerSuite) TestRunContainerWithCgroupParent(c *check.C) {
2939
-	testRequires(c, NativeExecDriver)
2939
+	// Not applicable on Windows as uses Unix specific functionality
2940
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2940 2941
 
2941 2942
 	cgroupParent := "test"
2942 2943
 	name := "cgroup-test"
... ...
@@ -2965,7 +3205,8 @@ func (s *DockerSuite) TestRunContainerWithCgroupParent(c *check.C) {
2965 2965
 }
2966 2966
 
2967 2967
 func (s *DockerSuite) TestRunContainerWithCgroupParentAbsPath(c *check.C) {
2968
-	testRequires(c, NativeExecDriver)
2968
+	// Not applicable on Windows as uses Unix specific functionality
2969
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2969 2970
 
2970 2971
 	cgroupParent := "/cgroup-parent/test"
2971 2972
 	name := "cgroup-test"
... ...
@@ -2993,7 +3234,8 @@ func (s *DockerSuite) TestRunContainerWithCgroupParentAbsPath(c *check.C) {
2993 2993
 }
2994 2994
 
2995 2995
 func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *check.C) {
2996
-	testRequires(c, NativeExecDriver)
2996
+	// Not applicable on Windows as uses Unix specific functionality
2997
+	testRequires(c, DaemonIsLinux, NativeExecDriver)
2997 2998
 
2998 2999
 	filename := "/sys/fs/cgroup/devices/test123"
2999 3000
 	out, _, err := dockerCmdWithError("run", "busybox", "touch", filename)
... ...
@@ -3007,6 +3249,7 @@ func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *check.C) {
3007 3007
 }
3008 3008
 
3009 3009
 func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *check.C) {
3010
+	// Not applicable on Windows which does not support --net=container
3010 3011
 	testRequires(c, DaemonIsLinux)
3011 3012
 	out, _, err := dockerCmdWithError("run", "--name=me", "--net=container:me", "busybox", "true")
3012 3013
 	if err == nil || !strings.Contains(out, "cannot join own network") {
... ...
@@ -3015,6 +3258,7 @@ func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *check.C) {
3015 3015
 }
3016 3016
 
3017 3017
 func (s *DockerSuite) TestRunContainerNetModeWithDnsMacHosts(c *check.C) {
3018
+	// Not applicable on Windows which does not support --net=container
3018 3019
 	testRequires(c, DaemonIsLinux)
3019 3020
 	out, _, err := dockerCmdWithError("run", "-d", "--name", "parent", "busybox", "top")
3020 3021
 	if err != nil {
... ...
@@ -3038,6 +3282,7 @@ func (s *DockerSuite) TestRunContainerNetModeWithDnsMacHosts(c *check.C) {
3038 3038
 }
3039 3039
 
3040 3040
 func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *check.C) {
3041
+	// Not applicable on Windows which does not support --net=container
3041 3042
 	testRequires(c, DaemonIsLinux)
3042 3043
 	dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
3043 3044
 
... ...
@@ -3058,6 +3303,7 @@ func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *check.C) {
3058 3058
 }
3059 3059
 
3060 3060
 func (s *DockerSuite) TestRunLinkToContainerNetMode(c *check.C) {
3061
+	// Not applicable on Windows which does not support --net=container or --link
3061 3062
 	testRequires(c, DaemonIsLinux)
3062 3063
 	dockerCmd(c, "run", "--name", "test", "-d", "busybox", "top")
3063 3064
 	dockerCmd(c, "run", "--name", "parent", "-d", "--net=container:test", "busybox", "top")
... ...
@@ -3067,6 +3313,7 @@ func (s *DockerSuite) TestRunLinkToContainerNetMode(c *check.C) {
3067 3067
 }
3068 3068
 
3069 3069
 func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C) {
3070
+	// TODO Windows: This may be possible to convert.
3070 3071
 	testRequires(c, DaemonIsLinux)
3071 3072
 	out, _ := dockerCmd(c, "run", "--net=none", "busybox", "ip", "-o", "-4", "a", "show", "up")
3072 3073
 
... ...
@@ -3092,11 +3339,15 @@ func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C
3092 3092
 
3093 3093
 // Issue #4681
3094 3094
 func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) {
3095
-	testRequires(c, DaemonIsLinux)
3096
-	dockerCmd(c, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1")
3095
+	if daemonPlatform == "windows" {
3096
+		dockerCmd(c, "run", "--net=none", WindowsBaseImage, "ping", "-n", "1", "127.0.0.1")
3097
+	} else {
3098
+		dockerCmd(c, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1")
3099
+	}
3097 3100
 }
3098 3101
 
3099 3102
 func (s *DockerSuite) TestRunModeNetContainerHostname(c *check.C) {
3103
+	// Windows does not support --net=container
3100 3104
 	testRequires(c, DaemonIsLinux, ExecSupport)
3101 3105
 
3102 3106
 	dockerCmd(c, "run", "-i", "-d", "--name", "parent", "busybox", "top")
... ...
@@ -3109,6 +3360,8 @@ func (s *DockerSuite) TestRunModeNetContainerHostname(c *check.C) {
3109 3109
 }
3110 3110
 
3111 3111
 func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *check.C) {
3112
+	// TODO Windows: Network settings are not currently propagated. This may
3113
+	// be resolved in the future with the move to libnetwork and CNM.
3112 3114
 	testRequires(c, DaemonIsLinux)
3113 3115
 	out, _ := dockerCmd(c, "run", "-d", "--net=none", "busybox", "top")
3114 3116
 	id := strings.TrimSpace(out)
... ...
@@ -3120,6 +3373,7 @@ func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *check.C) {
3120 3120
 }
3121 3121
 
3122 3122
 func (s *DockerSuite) TestTwoContainersInNetHost(c *check.C) {
3123
+	// Not applicable as Windows does not support --net=host
3123 3124
 	testRequires(c, DaemonIsLinux)
3124 3125
 	dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
3125 3126
 	dockerCmd(c, "run", "-d", "--net=host", "--name=second", "busybox", "top")
... ...
@@ -15,7 +15,7 @@ func (s *DockerSuite) TestWaitNonBlockedExitZero(c *check.C) {
15 15
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "true")
16 16
 	containerID := strings.TrimSpace(out)
17 17
 
18
-	if err := waitInspect(containerID, "{{.State.Running}}", "false", 1); err != nil {
18
+	if err := waitInspect(containerID, "{{.State.Running}}", "false", 1*time.Second); err != nil {
19 19
 		c.Fatal("Container should have stopped by now")
20 20
 	}
21 21
 
... ...
@@ -60,7 +60,7 @@ func (s *DockerSuite) TestWaitNonBlockedExitRandom(c *check.C) {
60 60
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "exit 99")
61 61
 	containerID := strings.TrimSpace(out)
62 62
 
63
-	if err := waitInspect(containerID, "{{.State.Running}}", "false", 1); err != nil {
63
+	if err := waitInspect(containerID, "{{.State.Running}}", "false", 1*time.Second); err != nil {
64 64
 		c.Fatal("Container should have stopped by now")
65 65
 	}
66 66
 
... ...
@@ -34,6 +34,19 @@ var (
34 34
 	// of the daemon. This is initialised in docker_utils by sending
35 35
 	// a version call to the daemon and examining the response header.
36 36
 	daemonPlatform string
37
+
38
+	// daemonDefaultImage is the name of the default image to use when running
39
+	// tests. This is platform dependent.
40
+	daemonDefaultImage string
41
+)
42
+
43
+const (
44
+	// WindowsBaseImage is the name of the base image for Windows testing
45
+	WindowsBaseImage = "windowsservercore"
46
+
47
+	// DefaultImage is the name of the base image for the majority of tests that
48
+	// are run across suites
49
+	DefaultImage = "busybox"
37 50
 )
38 51
 
39 52
 func init() {
... ...
@@ -1402,14 +1402,20 @@ func waitForContainer(contID string, args ...string) error {
1402 1402
 
1403 1403
 // waitRun will wait for the specified container to be running, maximum 5 seconds.
1404 1404
 func waitRun(contID string) error {
1405
-	return waitInspect(contID, "{{.State.Running}}", "true", 5)
1405
+	return waitInspect(contID, "{{.State.Running}}", "true", 5*time.Second)
1406
+}
1407
+
1408
+// waitExited will wait for the specified container to state exit, subject
1409
+// to a maximum time limit in seconds supplied by the caller
1410
+func waitExited(contID string, duration time.Duration) error {
1411
+	return waitInspect(contID, "{{.State.Status}}", "exited", duration)
1406 1412
 }
1407 1413
 
1408 1414
 // waitInspect will wait for the specified container to have the specified string
1409 1415
 // in the inspect output. It will wait until the specified timeout (in seconds)
1410 1416
 // is reached.
1411
-func waitInspect(name, expr, expected string, timeout int) error {
1412
-	after := time.After(time.Duration(timeout) * time.Second)
1417
+func waitInspect(name, expr, expected string, timeout time.Duration) error {
1418
+	after := time.After(timeout)
1413 1419
 
1414 1420
 	for {
1415 1421
 		cmd := exec.Command(dockerBinary, "inspect", "-f", expr, name)