Browse code

add test-integration-cli specifics for userns

Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <acidburn@docker.com>

Jessica Frazelle authored on 2015/09/19 02:41:12
Showing 21 changed files
... ...
@@ -9,6 +9,7 @@ DOCKER_ENVS := \
9 9
 	-e DOCKER_DEBUG \
10 10
 	-e DOCKER_EXECDRIVER \
11 11
 	-e DOCKER_EXPERIMENTAL \
12
+	-e DOCKER_REMAP_ROOT \
12 13
 	-e DOCKER_GRAPHDRIVER \
13 14
 	-e DOCKER_STORAGE_OPTS \
14 15
 	-e DOCKER_USERLANDPROXY \
... ...
@@ -96,7 +96,7 @@ if [ ! "$GOPATH" ]; then
96 96
 	exit 1
97 97
 fi
98 98
 
99
-if [ "$DOCKER_EXPERIMENTAL" ]; then
99
+if [ "$DOCKER_EXPERIMENTAL" ] || [ "$DOCKER_REMAP_ROOT" ]; then
100 100
 	echo >&2 '# WARNING! DOCKER_EXPERIMENTAL is set: building experimental features'
101 101
 	echo >&2
102 102
 	DOCKER_BUILDTAGS+=" experimental"
... ...
@@ -26,6 +26,12 @@ if [ -n "$DOCKER_STORAGE_OPTS" ]; then
26 26
 	unset IFS
27 27
 fi
28 28
 
29
+# example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
30
+extra_params=""
31
+if [ "$DOCKER_REMAP_ROOT" ]; then
32
+	extra_params="--root $DOCKER_REMAP_ROOT"
33
+fi
34
+
29 35
 if [ -z "$DOCKER_TEST_HOST" ]; then
30 36
 	# Start apparmor if it is enabled
31 37
 	if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
... ...
@@ -47,6 +53,7 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
47 47
 		--pidfile "$DEST/docker.pid" \
48 48
 		--userland-proxy="$DOCKER_USERLANDPROXY" \
49 49
 		$storage_params \
50
+		$extra_params \
50 51
 			&> "$DEST/docker.log"
51 52
 	) &
52 53
 	# make sure that if the script exits unexpectedly, we stop this daemon we just started
... ...
@@ -45,6 +45,7 @@ func (s *DockerSuite) TestBuildApiDockerfilePath(c *check.C) {
45 45
 }
46 46
 
47 47
 func (s *DockerSuite) TestBuildApiDockerFileRemote(c *check.C) {
48
+	testRequires(c, NotUserNamespace)
48 49
 	testRequires(c, DaemonIsLinux)
49 50
 	server, err := fakeStorage(map[string]string{
50 51
 		"testD": `FROM busybox
... ...
@@ -1487,7 +1487,9 @@ func (s *DockerSuite) TestContainersApiCreateNoHostConfig118(c *check.C) {
1487 1487
 // extract an archive to a symlink in a writable volume which points to a
1488 1488
 // directory outside of the volume.
1489 1489
 func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(c *check.C) {
1490
-	testRequires(c, SameHostDaemon) // Requires local volume mount bind.
1490
+	// Requires local volume mount bind.
1491
+	// --read-only + userns has remount issues
1492
+	testRequires(c, SameHostDaemon, NotUserNamespace)
1491 1493
 
1492 1494
 	testVol := getTestDir(c, "test-put-container-archive-err-symlink-in-volume-to-read-only-rootfs-")
1493 1495
 	defer os.RemoveAll(testVol)
... ...
@@ -2183,6 +2183,8 @@ func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) {
2183 2183
 }
2184 2184
 
2185 2185
 func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) {
2186
+	// cat /test1/test2/foo gets permission denied for the user
2187
+	testRequires(c, NotUserNamespace)
2186 2188
 	testRequires(c, DaemonIsLinux)
2187 2189
 	name := "testbuildrelativecopy"
2188 2190
 	dockerfile := `
... ...
@@ -2683,6 +2685,8 @@ func (s *DockerSuite) TestBuildConditionalCache(c *check.C) {
2683 2683
 }
2684 2684
 
2685 2685
 func (s *DockerSuite) TestBuildAddLocalFileWithCache(c *check.C) {
2686
+	// local files are not owned by the correct user
2687
+	testRequires(c, NotUserNamespace)
2686 2688
 	testRequires(c, DaemonIsLinux)
2687 2689
 	name := "testbuildaddlocalfilewithcache"
2688 2690
 	name2 := "testbuildaddlocalfilewithcache2"
... ...
@@ -2741,6 +2745,8 @@ func (s *DockerSuite) TestBuildAddMultipleLocalFileWithCache(c *check.C) {
2741 2741
 }
2742 2742
 
2743 2743
 func (s *DockerSuite) TestBuildAddLocalFileWithoutCache(c *check.C) {
2744
+	// local files are not owned by the correct user
2745
+	testRequires(c, NotUserNamespace)
2744 2746
 	testRequires(c, DaemonIsLinux)
2745 2747
 	name := "testbuildaddlocalfilewithoutcache"
2746 2748
 	name2 := "testbuildaddlocalfilewithoutcache2"
... ...
@@ -3862,6 +3868,8 @@ RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1042:1043/10
3862 3862
 }
3863 3863
 
3864 3864
 func (s *DockerSuite) TestBuildEnvUsage(c *check.C) {
3865
+	// /docker/world/hello is not owned by the correct user
3866
+	testRequires(c, NotUserNamespace)
3865 3867
 	testRequires(c, DaemonIsLinux)
3866 3868
 	name := "testbuildenvusage"
3867 3869
 	dockerfile := `FROM busybox
... ...
@@ -3898,6 +3906,8 @@ RUN    [ "$ghi" = "def" ]
3898 3898
 }
3899 3899
 
3900 3900
 func (s *DockerSuite) TestBuildEnvUsage2(c *check.C) {
3901
+	// /docker/world/hello is not owned by the correct user
3902
+	testRequires(c, NotUserNamespace)
3901 3903
 	testRequires(c, DaemonIsLinux)
3902 3904
 	name := "testbuildenvusage2"
3903 3905
 	dockerfile := `FROM busybox
... ...
@@ -4024,6 +4034,8 @@ RUN [ "$(cat /testfile)" = 'test!' ]`
4024 4024
 }
4025 4025
 
4026 4026
 func (s *DockerSuite) TestBuildAddTar(c *check.C) {
4027
+	// /test/foo is not owned by the correct user
4028
+	testRequires(c, NotUserNamespace)
4027 4029
 	testRequires(c, DaemonIsLinux)
4028 4030
 	name := "testbuildaddtar"
4029 4031
 
... ...
@@ -4080,7 +4092,8 @@ RUN cat /existing-directory-trailing-slash/test/foo | grep Hi`
4080 4080
 }
4081 4081
 
4082 4082
 func (s *DockerSuite) TestBuildAddTarXz(c *check.C) {
4083
-	testRequires(c, DaemonIsLinux)
4083
+	// /test/foo is not owned by the correct user
4084
+	testRequires(c, NotUserNamespace)
4084 4085
 	testRequires(c, DaemonIsLinux)
4085 4086
 	name := "testbuildaddtarxz"
4086 4087
 
... ...
@@ -4839,6 +4852,8 @@ func (s *DockerSuite) TestBuildSymlinkBreakout(c *check.C) {
4839 4839
 }
4840 4840
 
4841 4841
 func (s *DockerSuite) TestBuildXZHost(c *check.C) {
4842
+	// /usr/local/sbin/xz gets permission denied for the user
4843
+	testRequires(c, NotUserNamespace)
4842 4844
 	testRequires(c, DaemonIsLinux)
4843 4845
 	name := "testbuildxzhost"
4844 4846
 
... ...
@@ -4867,6 +4882,8 @@ RUN [ ! -e /injected ]`,
4867 4867
 }
4868 4868
 
4869 4869
 func (s *DockerSuite) TestBuildVolumesRetainContents(c *check.C) {
4870
+	// /foo/file gets permission denied for the user
4871
+	testRequires(c, NotUserNamespace)
4870 4872
 	testRequires(c, DaemonIsLinux)
4871 4873
 	var (
4872 4874
 		name     = "testbuildvolumescontent"
... ...
@@ -589,6 +589,8 @@ func (s *DockerSuite) TestCpSpecialFiles(c *check.C) {
589 589
 }
590 590
 
591 591
 func (s *DockerSuite) TestCpVolumePath(c *check.C) {
592
+	//  stat /tmp/cp-test-volumepath851508420/test gets permission denied for the user
593
+	testRequires(c, NotUserNamespace)
592 594
 	testRequires(c, DaemonIsLinux)
593 595
 	testRequires(c, SameHostDaemon)
594 596
 
... ...
@@ -153,6 +153,8 @@ func (s *DockerSuite) TestCpToErrDstNotDir(c *check.C) {
153 153
 // Check that copying from a local path to a symlink in a container copies to
154 154
 // the symlink target and does not overwrite the container symlink itself.
155 155
 func (s *DockerSuite) TestCpToSymlinkDestination(c *check.C) {
156
+	//  stat /tmp/test-cp-to-symlink-destination-262430901/vol3 gets permission denied for the user
157
+	testRequires(c, NotUserNamespace)
156 158
 	testRequires(c, DaemonIsLinux)
157 159
 	testRequires(c, SameHostDaemon) // Requires local volume mount bind.
158 160
 
... ...
@@ -699,7 +701,8 @@ func (s *DockerSuite) TestCpToCaseJ(c *check.C) {
699 699
 // The `docker cp` command should also ensure that you cannot
700 700
 // write to a container rootfs that is marked as read-only.
701 701
 func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *check.C) {
702
-	testRequires(c, DaemonIsLinux)
702
+	// --read-only + userns has remount issues
703
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
703 704
 	tmpDir := getTestDir(c, "test-cp-to-err-read-only-rootfs")
704 705
 	defer os.RemoveAll(tmpDir)
705 706
 
... ...
@@ -732,7 +735,8 @@ func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *check.C) {
732 732
 // The `docker cp` command should also ensure that you
733 733
 // cannot write to a volume that is mounted as read-only.
734 734
 func (s *DockerSuite) TestCpToErrReadOnlyVolume(c *check.C) {
735
-	testRequires(c, DaemonIsLinux)
735
+	// --read-only + userns has remount issues
736
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
736 737
 	tmpDir := getTestDir(c, "test-cp-to-err-read-only-volume")
737 738
 	defer os.RemoveAll(tmpDir)
738 739
 
... ...
@@ -276,7 +276,7 @@ func (s *DockerSuite) TestCreateRM(c *check.C) {
276 276
 
277 277
 func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) {
278 278
 	testRequires(c, DaemonIsLinux)
279
-	testRequires(c, SameHostDaemon)
279
+	testRequires(c, SameHostDaemon, NotUserNamespace)
280 280
 
281 281
 	out, _ := dockerCmd(c, "create", "busybox")
282 282
 	id := strings.TrimSpace(out)
... ...
@@ -1483,7 +1483,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterCrash(c *check.C) {
1483 1483
 }
1484 1484
 
1485 1485
 func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) {
1486
-	testRequires(c, NativeExecDriver)
1486
+	testRequires(c, NativeExecDriver, NotUserNamespace)
1487 1487
 	c.Assert(s.d.StartWithBusybox("-b", "none"), check.IsNil)
1488 1488
 
1489 1489
 	out, err := s.d.Cmd("run", "--rm", "busybox", "ip", "l")
... ...
@@ -265,6 +265,7 @@ func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
265 265
 }
266 266
 
267 267
 func (s *DockerSuite) TestExecCgroup(c *check.C) {
268
+	testRequires(c, NotUserNamespace)
268 269
 	testRequires(c, DaemonIsLinux)
269 270
 	dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
270 271
 
... ...
@@ -547,7 +548,7 @@ func (s *DockerSuite) TestExecWithUser(c *check.C) {
547 547
 }
548 548
 
549 549
 func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
550
-	testRequires(c, DaemonIsLinux)
550
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
551 551
 	// Start main loop which attempts mknod repeatedly
552 552
 	dockerCmd(c, "run", "-d", "--name", "parent", "--cap-drop=ALL", "busybox", "sh", "-c", `while (true); do if [ -e /exec_priv ]; then cat /exec_priv && mknod /tmp/sda b 8 0 && echo "Success"; else echo "Privileged exec has not run yet"; fi; usleep 10000; done`)
553 553
 
... ...
@@ -605,7 +606,8 @@ func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
605 605
 }
606 606
 
607 607
 func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
608
-	testRequires(c, DaemonIsLinux)
608
+	// --read-only + userns has remount issues
609
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
609 610
 	dockerCmd(c, "run", "-d", "--read-only", "--name", "parent", "busybox", "top")
610 611
 	if _, status := dockerCmd(c, "exec", "parent", "true"); status != 0 {
611 612
 		c.Fatalf("exec into a read-only container failed with exit status %d", status)
... ...
@@ -2,10 +2,11 @@ package main
2 2
 
3 3
 import (
4 4
 	"fmt"
5
-	"github.com/go-check/check"
6 5
 	"reflect"
7 6
 	"regexp"
8 7
 	"strings"
8
+
9
+	"github.com/go-check/check"
9 10
 )
10 11
 
11 12
 func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *check.C) {
... ...
@@ -233,7 +234,7 @@ func (s *DockerSuite) TestLinkShortDefinition(c *check.C) {
233 233
 }
234 234
 
235 235
 func (s *DockerSuite) TestLinksNetworkHostContainer(c *check.C) {
236
-	testRequires(c, DaemonIsLinux)
236
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
237 237
 	dockerCmd(c, "run", "-d", "--net", "host", "--name", "host_container", "busybox", "top")
238 238
 	out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true")
239 239
 	if err == nil || !strings.Contains(out, "--net=host can't be used with links. This would result in undefined behavior") {
... ...
@@ -242,7 +243,7 @@ func (s *DockerSuite) TestLinksNetworkHostContainer(c *check.C) {
242 242
 }
243 243
 
244 244
 func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *check.C) {
245
-	testRequires(c, DaemonIsLinux)
245
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
246 246
 	out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts")
247 247
 	if !strings.HasPrefix(out, "-") {
248 248
 		c.Errorf("/etc/hosts should be a regular file")
... ...
@@ -12,7 +12,7 @@ import (
12 12
 func (s *DockerSuite) TestLinksEtcHostsContentMatch(c *check.C) {
13 13
 	// In a _unix file as using Unix specific files, and must be on the
14 14
 	// same host as the daemon.
15
-	testRequires(c, SameHostDaemon)
15
+	testRequires(c, SameHostDaemon, NotUserNamespace)
16 16
 
17 17
 	out, _ := dockerCmd(c, "run", "--net=host", "busybox", "cat", "/etc/hosts")
18 18
 	hosts, err := ioutil.ReadFile("/etc/hosts")
... ...
@@ -98,7 +98,7 @@ func (s *DockerSuite) TestNetworkLocalhostTCPNat(c *check.C) {
98 98
 
99 99
 func (s *DockerSuite) TestNetworkLoopbackNat(c *check.C) {
100 100
 	testRequires(c, DaemonIsLinux)
101
-	testRequires(c, SameHostDaemon, NativeExecDriver)
101
+	testRequires(c, SameHostDaemon, NativeExecDriver, NotUserNamespace)
102 102
 	msg := "it works"
103 103
 	startServerContainer(c, msg, 8080)
104 104
 	endpoint := getExternalAddress(c)
... ...
@@ -23,7 +23,7 @@ func checkContains(expected string, out string, c *check.C) {
23 23
 }
24 24
 
25 25
 func (s *DockerSuite) TestNetHostname(c *check.C) {
26
-	testRequires(c, DaemonIsLinux)
26
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
27 27
 
28 28
 	var (
29 29
 		out    string
... ...
@@ -81,7 +81,7 @@ func (s *DockerSuite) TestNetHostname(c *check.C) {
81 81
 }
82 82
 
83 83
 func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *check.C) {
84
-	testRequires(c, DaemonIsLinux)
84
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
85 85
 	var (
86 86
 		out    string
87 87
 		err    error
... ...
@@ -102,7 +102,7 @@ func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *check.C) {
102 102
 }
103 103
 
104 104
 func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *check.C) {
105
-	testRequires(c, DaemonIsLinux)
105
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
106 106
 	var (
107 107
 		out    string
108 108
 		err    error
... ...
@@ -249,7 +249,7 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *check.C) {
249 249
 }
250 250
 
251 251
 func (s *DockerSuite) TestPortHostBinding(c *check.C) {
252
-	testRequires(c, DaemonIsLinux)
252
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
253 253
 	out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox",
254 254
 		"nc", "-l", "-p", "80")
255 255
 	firstID := strings.TrimSpace(out)
... ...
@@ -272,7 +272,7 @@ func (s *DockerSuite) TestPortHostBinding(c *check.C) {
272 272
 }
273 273
 
274 274
 func (s *DockerSuite) TestPortExposeHostBinding(c *check.C) {
275
-	testRequires(c, DaemonIsLinux)
275
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
276 276
 	out, _ := dockerCmd(c, "run", "-d", "-P", "--expose", "80", "busybox",
277 277
 		"nc", "-l", "-p", "80")
278 278
 	firstID := strings.TrimSpace(out)
... ...
@@ -707,7 +707,7 @@ func (s *DockerSuite) TestRunContainerNetwork(c *check.C) {
707 707
 func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *check.C) {
708 708
 	// TODO Windows: This is Linux specific as --link is not supported and
709 709
 	// this will be deprecated in favour of container networking model.
710
-	testRequires(c, DaemonIsLinux)
710
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
711 711
 	dockerCmd(c, "run", "--name", "linked", "busybox", "true")
712 712
 
713 713
 	_, _, err := dockerCmdWithError("run", "--net=host", "--link", "linked:linked", "busybox", "true")
... ...
@@ -733,7 +733,7 @@ func (s *DockerSuite) TestRunFullHostnameSet(c *check.C) {
733 733
 func (s *DockerSuite) TestRunPrivilegedCanMknod(c *check.C) {
734 734
 	// Not applicable for Windows as Windows daemon does not support
735 735
 	// the concept of --privileged, and mknod is a Unix concept.
736
-	testRequires(c, DaemonIsLinux)
736
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
737 737
 	out, _ := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
738 738
 	if actual := strings.Trim(out, "\r\n"); actual != "ok" {
739 739
 		c.Fatalf("expected output ok received %s", actual)
... ...
@@ -743,7 +743,7 @@ func (s *DockerSuite) TestRunPrivilegedCanMknod(c *check.C) {
743 743
 func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *check.C) {
744 744
 	// Not applicable for Windows as Windows daemon does not support
745 745
 	// the concept of --privileged, and mknod is a Unix concept.
746
-	testRequires(c, DaemonIsLinux)
746
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
747 747
 	out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
748 748
 	if actual := strings.Trim(out, "\r\n"); actual != "ok" {
749 749
 		c.Fatalf("expected output ok received %s", actual)
... ...
@@ -799,7 +799,7 @@ func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *check.C) {
799 799
 
800 800
 func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *check.C) {
801 801
 	// Not applicable for Windows as there is no concept of --cap-drop or mknod
802
-	testRequires(c, DaemonIsLinux)
802
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
803 803
 	out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=MKNOD", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
804 804
 
805 805
 	if actual := strings.Trim(out, "\r\n"); actual != "ok" {
... ...
@@ -861,7 +861,7 @@ func (s *DockerSuite) TestRunGroupAdd(c *check.C) {
861 861
 
862 862
 func (s *DockerSuite) TestRunPrivilegedCanMount(c *check.C) {
863 863
 	// Not applicable for Windows as there is no concept of --privileged
864
-	testRequires(c, DaemonIsLinux)
864
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
865 865
 	out, _ := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
866 866
 
867 867
 	if actual := strings.Trim(out, "\r\n"); actual != "ok" {
... ...
@@ -892,7 +892,7 @@ func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *check.C)
892 892
 
893 893
 func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *check.C) {
894 894
 	// Not applicable for Windows as there is no concept of unprivileged
895
-	testRequires(c, DaemonIsLinux)
895
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
896 896
 	if _, code, err := dockerCmdWithError("run", "--privileged", "busybox", "touch", "/sys/kernel/profiling"); err != nil || code != 0 {
897 897
 		c.Fatalf("sys should be writable in privileged container")
898 898
 	}
... ...
@@ -908,7 +908,7 @@ func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *check.C
908 908
 
909 909
 func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *check.C) {
910 910
 	// Not applicable for Windows as there is no concept of --privileged
911
-	testRequires(c, DaemonIsLinux)
911
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
912 912
 	if _, code := dockerCmd(c, "run", "--privileged", "busybox", "touch", "/proc/sysrq-trigger"); code != 0 {
913 913
 		c.Fatalf("proc should be writable in privileged container")
914 914
 	}
... ...
@@ -916,7 +916,8 @@ func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *check.C) {
916 916
 
917 917
 func (s *DockerSuite) TestRunDeviceNumbers(c *check.C) {
918 918
 	// Not applicable on Windows as /dev/ is a Unix specific concept
919
-	testRequires(c, DaemonIsLinux)
919
+	// TODO: NotUserNamespace could be removed here if "root" "root" is replaced w user
920
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
920 921
 	out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "ls -l /dev/null")
921 922
 	deviceLineFields := strings.Fields(out)
922 923
 	deviceLineFields[6] = ""
... ...
@@ -946,7 +947,7 @@ func (s *DockerSuite) TestRunUnprivilegedWithChroot(c *check.C) {
946 946
 
947 947
 func (s *DockerSuite) TestRunAddingOptionalDevices(c *check.C) {
948 948
 	// Not applicable on Windows as Windows does not support --device
949
-	testRequires(c, DaemonIsLinux)
949
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
950 950
 	out, _ := dockerCmd(c, "run", "--device", "/dev/zero:/dev/nulo", "busybox", "sh", "-c", "ls /dev/nulo")
951 951
 	if actual := strings.Trim(out, "\r\n"); actual != "/dev/nulo" {
952 952
 		c.Fatalf("expected output /dev/nulo, received %s", actual)
... ...
@@ -955,7 +956,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevices(c *check.C) {
955 955
 
956 956
 func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *check.C) {
957 957
 	// Not applicable on Windows as Windows does not support --device
958
-	testRequires(c, DaemonIsLinux)
958
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
959 959
 	out, _ := dockerCmd(c, "run", "--device", "/dev/zero:rw", "busybox", "sh", "-c", "ls /dev/zero")
960 960
 	if actual := strings.Trim(out, "\r\n"); actual != "/dev/zero" {
961 961
 		c.Fatalf("expected output /dev/zero, received %s", actual)
... ...
@@ -964,7 +965,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *check.C) {
964 964
 
965 965
 func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *check.C) {
966 966
 	// Not applicable on Windows as Windows does not support --device
967
-	testRequires(c, DaemonIsLinux)
967
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
968 968
 	_, _, err := dockerCmdWithError("run", "--device", "/dev/zero:ro", "busybox", "sh", "-c", "ls /dev/zero")
969 969
 	if err == nil {
970 970
 		c.Fatalf("run container with device mode ro should fail")
... ...
@@ -973,7 +974,7 @@ func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *check.C) {
973 973
 
974 974
 func (s *DockerSuite) TestRunModeHostname(c *check.C) {
975 975
 	// Not applicable on Windows as Windows does not support -h
976
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
976
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
977 977
 
978 978
 	out, _ := dockerCmd(c, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
979 979
 
... ...
@@ -1711,6 +1712,8 @@ func (s *DockerSuite) TestRunEntrypoint(c *check.C) {
1711 1711
 }
1712 1712
 
1713 1713
 func (s *DockerSuite) TestRunBindMounts(c *check.C) {
1714
+	// /tmp gets permission denied
1715
+	testRequires(c, NotUserNamespace)
1714 1716
 	// Cannot run on Windows as Windows does not support volumes
1715 1717
 	testRequires(c, DaemonIsLinux, SameHostDaemon)
1716 1718
 
... ...
@@ -1909,6 +1912,8 @@ func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *check.C) {
1909 1909
 
1910 1910
 // Regression test for #7792
1911 1911
 func (s *DockerSuite) TestRunMountOrdering(c *check.C) {
1912
+	// tmp gets permission denied
1913
+	testRequires(c, NotUserNamespace)
1912 1914
 	// Not applicable on Windows as Windows does not support volumes
1913 1915
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1914 1916
 
... ...
@@ -1953,6 +1958,8 @@ func (s *DockerSuite) TestRunMountOrdering(c *check.C) {
1953 1953
 
1954 1954
 // Regression test for https://github.com/docker/docker/issues/8259
1955 1955
 func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *check.C) {
1956
+	// /tmp gets permission denied
1957
+	testRequires(c, NotUserNamespace)
1956 1958
 	// Not applicable on Windows as Windows does not support volumes
1957 1959
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
1958 1960
 
... ...
@@ -2157,7 +2164,7 @@ func (s *DockerSuite) TestRunUnknownCommand(c *check.C) {
2157 2157
 
2158 2158
 func (s *DockerSuite) TestRunModeIpcHost(c *check.C) {
2159 2159
 	// Not applicable on Windows as uses Unix-specific capabilities
2160
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2160
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2161 2161
 
2162 2162
 	hostIpc, err := os.Readlink("/proc/1/ns/ipc")
2163 2163
 	if err != nil {
... ...
@@ -2179,7 +2186,7 @@ func (s *DockerSuite) TestRunModeIpcHost(c *check.C) {
2179 2179
 
2180 2180
 func (s *DockerSuite) TestRunModeIpcContainer(c *check.C) {
2181 2181
 	// Not applicable on Windows as uses Unix-specific capabilities
2182
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2182
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2183 2183
 
2184 2184
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "echo -n test > /dev/shm/test && top")
2185 2185
 
... ...
@@ -2211,7 +2218,7 @@ func (s *DockerSuite) TestRunModeIpcContainer(c *check.C) {
2211 2211
 
2212 2212
 func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *check.C) {
2213 2213
 	// Not applicable on Windows as uses Unix-specific capabilities
2214
-	testRequires(c, DaemonIsLinux)
2214
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
2215 2215
 	out, _, err := dockerCmdWithError("run", "-d", "--ipc", "container:abcd1234", "busybox", "top")
2216 2216
 	if !strings.Contains(out, "abcd1234") || err == nil {
2217 2217
 		c.Fatalf("run IPC from a non exists container should with correct error out")
... ...
@@ -2220,7 +2227,7 @@ func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *check.C) {
2220 2220
 
2221 2221
 func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *check.C) {
2222 2222
 	// Not applicable on Windows as uses Unix-specific capabilities
2223
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2223
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2224 2224
 
2225 2225
 	out, _ := dockerCmd(c, "create", "busybox")
2226 2226
 
... ...
@@ -2250,7 +2257,7 @@ func (s *DockerSuite) TestRunMountShmMqueueFromHost(c *check.C) {
2250 2250
 
2251 2251
 func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
2252 2252
 	// Not applicable on Windows as uses Unix-specific capabilities
2253
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2253
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2254 2254
 
2255 2255
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
2256 2256
 	id := strings.TrimSpace(out)
... ...
@@ -2272,7 +2279,7 @@ func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
2272 2272
 
2273 2273
 func (s *DockerSuite) TestRunModePidHost(c *check.C) {
2274 2274
 	// Not applicable on Windows as uses Unix-specific capabilities
2275
-	testRequires(c, NativeExecDriver, SameHostDaemon, DaemonIsLinux)
2275
+	testRequires(c, NativeExecDriver, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2276 2276
 
2277 2277
 	hostPid, err := os.Readlink("/proc/1/ns/pid")
2278 2278
 	if err != nil {
... ...
@@ -2413,7 +2420,7 @@ func (s *DockerSuite) TestRunNonLocalMacAddress(c *check.C) {
2413 2413
 
2414 2414
 func (s *DockerSuite) TestRunNetHost(c *check.C) {
2415 2415
 	// Not applicable on Windows as uses Unix-specific capabilities
2416
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2416
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2417 2417
 
2418 2418
 	hostNet, err := os.Readlink("/proc/1/ns/net")
2419 2419
 	if err != nil {
... ...
@@ -2436,7 +2443,7 @@ func (s *DockerSuite) TestRunNetHost(c *check.C) {
2436 2436
 func (s *DockerSuite) TestRunNetHostTwiceSameName(c *check.C) {
2437 2437
 	// TODO Windows. As Windows networking evolves and converges towards
2438 2438
 	// CNM, this test may be possible to enable on Windows.
2439
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2439
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2440 2440
 
2441 2441
 	dockerCmd(c, "run", "--rm", "--name=thost", "--net=host", "busybox", "true")
2442 2442
 	dockerCmd(c, "run", "--rm", "--name=thost", "--net=host", "busybox", "true")
... ...
@@ -2444,7 +2451,7 @@ func (s *DockerSuite) TestRunNetHostTwiceSameName(c *check.C) {
2444 2444
 
2445 2445
 func (s *DockerSuite) TestRunNetContainerWhichHost(c *check.C) {
2446 2446
 	// Not applicable on Windows as uses Unix-specific capabilities
2447
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2447
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2448 2448
 
2449 2449
 	hostNet, err := os.Readlink("/proc/1/ns/net")
2450 2450
 	if err != nil {
... ...
@@ -2534,7 +2541,8 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
2534 2534
 func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
2535 2535
 	// Not applicable on Windows due to use of Unix specific functionality, plus
2536 2536
 	// the use of --read-only which is not supported.
2537
-	testRequires(c, DaemonIsLinux, NativeExecDriver)
2537
+	// --read-only + userns has remount issues
2538
+	testRequires(c, DaemonIsLinux, NativeExecDriver, NotUserNamespace)
2538 2539
 
2539 2540
 	// Ensure we have not broken writing /dev/pts
2540 2541
 	out, status := dockerCmd(c, "run", "--read-only", "--rm", "busybox", "mount")
... ...
@@ -2549,7 +2557,7 @@ func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
2549 2549
 
2550 2550
 func testReadOnlyFile(filename string, c *check.C) {
2551 2551
 	// Not applicable on Windows which does not support --read-only
2552
-	testRequires(c, NativeExecDriver, DaemonIsLinux)
2552
+	testRequires(c, NativeExecDriver, DaemonIsLinux, NotUserNamespace)
2553 2553
 
2554 2554
 	out, _, err := dockerCmdWithError("run", "--read-only", "--rm", "busybox", "touch", filename)
2555 2555
 	if err == nil {
... ...
@@ -2572,7 +2580,8 @@ func testReadOnlyFile(filename string, c *check.C) {
2572 2572
 
2573 2573
 func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *check.C) {
2574 2574
 	// Not applicable on Windows which does not support --link
2575
-	testRequires(c, NativeExecDriver, DaemonIsLinux)
2575
+	// --read-only + userns has remount issues
2576
+	testRequires(c, NativeExecDriver, DaemonIsLinux, NotUserNamespace)
2576 2577
 
2577 2578
 	dockerCmd(c, "run", "-d", "--name", "test-etc-hosts-ro-linked", "busybox", "top")
2578 2579
 
... ...
@@ -2583,9 +2592,9 @@ func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *
2583 2583
 }
2584 2584
 
2585 2585
 func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDnsFlag(c *check.C) {
2586
-	// Not applicable on Windows which does not support either --read-only or
2587
-	// --dns.
2588
-	testRequires(c, NativeExecDriver, DaemonIsLinux)
2586
+	// Not applicable on Windows which does not support either --read-only or --dns.
2587
+	// --read-only + userns has remount issues
2588
+	testRequires(c, NativeExecDriver, DaemonIsLinux, NotUserNamespace)
2589 2589
 
2590 2590
 	out, _ := dockerCmd(c, "run", "--read-only", "--dns", "1.1.1.1", "busybox", "/bin/cat", "/etc/resolv.conf")
2591 2591
 	if !strings.Contains(string(out), "1.1.1.1") {
... ...
@@ -2595,7 +2604,8 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDnsFlag(c *check.C)
2595 2595
 
2596 2596
 func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *check.C) {
2597 2597
 	// Not applicable on Windows which does not support --read-only
2598
-	testRequires(c, NativeExecDriver, DaemonIsLinux)
2598
+	// --read-only + userns has remount issues
2599
+	testRequires(c, NativeExecDriver, DaemonIsLinux, NotUserNamespace)
2599 2600
 
2600 2601
 	out, _ := dockerCmd(c, "run", "--read-only", "--add-host", "testreadonly:127.0.0.1", "busybox", "/bin/cat", "/etc/hosts")
2601 2602
 	if !strings.Contains(string(out), "testreadonly") {
... ...
@@ -2654,7 +2664,7 @@ func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *check.C)
2654 2654
 
2655 2655
 func (s *DockerSuite) TestRunPidHostWithChildIsKillable(c *check.C) {
2656 2656
 	// Not applicable on Windows as uses Unix specific functionality
2657
-	testRequires(c, DaemonIsLinux)
2657
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
2658 2658
 	name := "ibuildthecloud"
2659 2659
 	dockerCmd(c, "run", "-d", "--pid=host", "--name", name, "busybox", "sh", "-c", "sleep 30; echo hi")
2660 2660
 
... ...
@@ -2734,7 +2744,7 @@ func (s *DockerSuite) TestRunReadProcLatency(c *check.C) {
2734 2734
 
2735 2735
 func (s *DockerSuite) TestRunReadFilteredProc(c *check.C) {
2736 2736
 	// Not applicable on Windows as uses Unix specific functionality
2737
-	testRequires(c, Apparmor, DaemonIsLinux)
2737
+	testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace)
2738 2738
 
2739 2739
 	testReadPaths := []string{
2740 2740
 		"/proc/latency_stats",
... ...
@@ -2767,7 +2777,8 @@ func (s *DockerSuite) TestMountIntoProc(c *check.C) {
2767 2767
 
2768 2768
 func (s *DockerSuite) TestMountIntoSys(c *check.C) {
2769 2769
 	// Not applicable on Windows as uses Unix specific functionality
2770
-	testRequires(c, DaemonIsLinux, NativeExecDriver)
2770
+	testRequires(c, DaemonIsLinux)
2771
+	testRequires(c, NativeExecDriver, NotUserNamespace)
2771 2772
 	dockerCmd(c, "run", "-v", "/sys/fs/cgroup", "busybox", "true")
2772 2773
 }
2773 2774
 
... ...
@@ -2854,7 +2865,7 @@ func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) {
2854 2854
 
2855 2855
 func (s *DockerSuite) TestRunWriteFilteredProc(c *check.C) {
2856 2856
 	// Not applicable on Windows as uses Unix specific functionality
2857
-	testRequires(c, Apparmor, NativeExecDriver, DaemonIsLinux)
2857
+	testRequires(c, Apparmor, NativeExecDriver, DaemonIsLinux, NotUserNamespace)
2858 2858
 
2859 2859
 	testWritePaths := []string{
2860 2860
 		/* modprobe and core_pattern should both be denied by generic
... ...
@@ -2917,7 +2928,8 @@ func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *check.C) {
2917 2917
 
2918 2918
 func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *check.C) {
2919 2919
 	// Not applicable on Windows as uses Unix specific functionality
2920
-	testRequires(c, SameHostDaemon, DaemonIsLinux)
2920
+	// --read-only + userns has remount issues
2921
+	testRequires(c, SameHostDaemon, DaemonIsLinux, NotUserNamespace)
2921 2922
 
2922 2923
 	filename := createTmpFile(c, "test123")
2923 2924
 	defer os.Remove(filename)
... ...
@@ -3260,7 +3272,8 @@ func (s *DockerSuite) TestRunContainerWithCgroupParentAbsPath(c *check.C) {
3260 3260
 
3261 3261
 func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *check.C) {
3262 3262
 	// Not applicable on Windows as uses Unix specific functionality
3263
-	testRequires(c, DaemonIsLinux, NativeExecDriver)
3263
+	// --read-only + userns has remount issues
3264
+	testRequires(c, DaemonIsLinux, NativeExecDriver, NotUserNamespace)
3264 3265
 
3265 3266
 	filename := "/sys/fs/cgroup/devices/test123"
3266 3267
 	out, _, err := dockerCmdWithError("run", "busybox", "touch", filename)
... ...
@@ -3275,7 +3288,7 @@ func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *check.C) {
3275 3275
 
3276 3276
 func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *check.C) {
3277 3277
 	// Not applicable on Windows which does not support --net=container
3278
-	testRequires(c, DaemonIsLinux)
3278
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3279 3279
 	out, _, err := dockerCmdWithError("run", "--name=me", "--net=container:me", "busybox", "true")
3280 3280
 	if err == nil || !strings.Contains(out, "cannot join own network") {
3281 3281
 		c.Fatalf("using container net mode to self should result in an error\nerr: %q\nout: %s", err, out)
... ...
@@ -3284,7 +3297,7 @@ func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *check.C) {
3284 3284
 
3285 3285
 func (s *DockerSuite) TestRunContainerNetModeWithDnsMacHosts(c *check.C) {
3286 3286
 	// Not applicable on Windows which does not support --net=container
3287
-	testRequires(c, DaemonIsLinux)
3287
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3288 3288
 	out, _, err := dockerCmdWithError("run", "-d", "--name", "parent", "busybox", "top")
3289 3289
 	if err != nil {
3290 3290
 		c.Fatalf("failed to run container: %v, output: %q", err, out)
... ...
@@ -3308,7 +3321,7 @@ func (s *DockerSuite) TestRunContainerNetModeWithDnsMacHosts(c *check.C) {
3308 3308
 
3309 3309
 func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *check.C) {
3310 3310
 	// Not applicable on Windows which does not support --net=container
3311
-	testRequires(c, DaemonIsLinux)
3311
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3312 3312
 	dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
3313 3313
 
3314 3314
 	out, _, err := dockerCmdWithError("run", "-p", "5000:5000", "--net=container:parent", "busybox")
... ...
@@ -3329,7 +3342,7 @@ func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *check.C) {
3329 3329
 
3330 3330
 func (s *DockerSuite) TestRunLinkToContainerNetMode(c *check.C) {
3331 3331
 	// Not applicable on Windows which does not support --net=container or --link
3332
-	testRequires(c, DaemonIsLinux)
3332
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3333 3333
 	dockerCmd(c, "run", "--name", "test", "-d", "busybox", "top")
3334 3334
 	dockerCmd(c, "run", "--name", "parent", "-d", "--net=container:test", "busybox", "top")
3335 3335
 	dockerCmd(c, "run", "-d", "--link=parent:parent", "busybox", "top")
... ...
@@ -3373,7 +3386,7 @@ func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) {
3373 3373
 
3374 3374
 func (s *DockerSuite) TestRunModeNetContainerHostname(c *check.C) {
3375 3375
 	// Windows does not support --net=container
3376
-	testRequires(c, DaemonIsLinux, ExecSupport)
3376
+	testRequires(c, DaemonIsLinux, ExecSupport, NotUserNamespace)
3377 3377
 
3378 3378
 	dockerCmd(c, "run", "-i", "-d", "--name", "parent", "busybox", "top")
3379 3379
 	out, _ := dockerCmd(c, "exec", "parent", "cat", "/etc/hostname")
... ...
@@ -3399,7 +3412,7 @@ func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *check.C) {
3399 3399
 
3400 3400
 func (s *DockerSuite) TestTwoContainersInNetHost(c *check.C) {
3401 3401
 	// Not applicable as Windows does not support --net=host
3402
-	testRequires(c, DaemonIsLinux)
3402
+	testRequires(c, DaemonIsLinux, NotUserNamespace, NotUserNamespace)
3403 3403
 	dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
3404 3404
 	dockerCmd(c, "run", "-d", "--net=host", "--name=second", "busybox", "top")
3405 3405
 	dockerCmd(c, "stop", "first")
... ...
@@ -3407,7 +3420,7 @@ func (s *DockerSuite) TestTwoContainersInNetHost(c *check.C) {
3407 3407
 }
3408 3408
 
3409 3409
 func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *check.C) {
3410
-	testRequires(c, DaemonIsLinux)
3410
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3411 3411
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork")
3412 3412
 	dockerCmd(c, "run", "-d", "--net=testnetwork", "--name=first", "busybox", "top")
3413 3413
 	c.Assert(waitRun("first"), check.IsNil)
... ...
@@ -3418,7 +3431,7 @@ func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *check.C) {
3418 3418
 }
3419 3419
 
3420 3420
 func (s *DockerSuite) TestContainersInMultipleNetworks(c *check.C) {
3421
-	testRequires(c, DaemonIsLinux)
3421
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3422 3422
 	// Create 2 networks using bridge driver
3423 3423
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
3424 3424
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
... ...
@@ -3441,7 +3454,7 @@ func (s *DockerSuite) TestContainersInMultipleNetworks(c *check.C) {
3441 3441
 }
3442 3442
 
3443 3443
 func (s *DockerSuite) TestContainersNetworkIsolation(c *check.C) {
3444
-	testRequires(c, DaemonIsLinux)
3444
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3445 3445
 	// Create 2 networks using bridge driver
3446 3446
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
3447 3447
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
... ...
@@ -3473,7 +3486,7 @@ func (s *DockerSuite) TestContainersNetworkIsolation(c *check.C) {
3473 3473
 }
3474 3474
 
3475 3475
 func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *check.C) {
3476
-	testRequires(c, DaemonIsLinux)
3476
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3477 3477
 	// Create 2 networks using bridge driver
3478 3478
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
3479 3479
 	// Run and connect containers to testnetwork1
... ...
@@ -3495,7 +3508,7 @@ func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *check.C) {
3495 3495
 }
3496 3496
 
3497 3497
 func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *check.C) {
3498
-	testRequires(c, DaemonIsLinux)
3498
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3499 3499
 	// Create 2 networks using bridge driver
3500 3500
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
3501 3501
 	dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
... ...
@@ -3531,7 +3544,7 @@ func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *check.C) {
3531 3531
 }
3532 3532
 
3533 3533
 func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *check.C) {
3534
-	testRequires(c, DaemonIsLinux)
3534
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3535 3535
 	// Run a container with --net=host
3536 3536
 	dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
3537 3537
 	c.Assert(waitRun("first"), check.IsNil)
... ...
@@ -3547,7 +3560,7 @@ func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *check.C) {
3547 3547
 }
3548 3548
 
3549 3549
 func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *check.C) {
3550
-	testRequires(c, DaemonIsLinux)
3550
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3551 3551
 	dockerCmd(c, "run", "-d", "--name=first", "busybox", "top")
3552 3552
 	c.Assert(waitRun("first"), check.IsNil)
3553 3553
 	// Run second container in first container's network namespace
... ...
@@ -3568,7 +3581,7 @@ func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *check.C) {
3568 3568
 }
3569 3569
 
3570 3570
 func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *check.C) {
3571
-	testRequires(c, DaemonIsLinux)
3571
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
3572 3572
 	dockerCmd(c, "run", "-d", "--net=none", "--name=first", "busybox", "top")
3573 3573
 	c.Assert(waitRun("first"), check.IsNil)
3574 3574
 
... ...
@@ -57,6 +57,8 @@ func (s *DockerSuite) TestRunRedirectStdout(c *check.C) {
57 57
 
58 58
 // Test recursive bind mount works by default
59 59
 func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *check.C) {
60
+	// /tmp gets permission denied
61
+	testRequires(c, NotUserNamespace)
60 62
 	tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test")
61 63
 	if err != nil {
62 64
 		c.Fatal(err)
... ...
@@ -90,7 +92,7 @@ func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *check.C) {
90 90
 }
91 91
 
92 92
 func (s *DockerSuite) TestRunDeviceDirectory(c *check.C) {
93
-	testRequires(c, NativeExecDriver)
93
+	testRequires(c, NativeExecDriver, NotUserNamespace)
94 94
 	if _, err := os.Stat("/dev/snd"); err != nil {
95 95
 		c.Skip("Host does not have /dev/snd")
96 96
 	}
... ...
@@ -39,7 +39,7 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
39 39
 }
40 40
 
41 41
 func (s *DockerSuite) TestTopPrivileged(c *check.C) {
42
-	testRequires(c, DaemonIsLinux)
42
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
43 43
 	out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top")
44 44
 	cleanedContainerID := strings.TrimSpace(out)
45 45
 
... ...
@@ -107,6 +107,10 @@ func (d *Daemon) Start(arg ...string) error {
107 107
 		fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
108 108
 	)
109 109
 
110
+	if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
111
+		args = append(args, []string{"--root", root}...)
112
+	}
113
+
110 114
 	// If we don't explicitly set the log-level or debug flag(-D) then
111 115
 	// turn on debug mode
112 116
 	foundIt := false
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"io/ioutil"
7 7
 	"log"
8 8
 	"net/http"
9
+	"os"
9 10
 	"os/exec"
10 11
 	"strings"
11 12
 	"time"
... ...
@@ -147,6 +148,16 @@ var (
147 147
 		},
148 148
 		"Test requires native Golang compiler instead of GCCGO",
149 149
 	}
150
+	NotUserNamespace = testRequirement{
151
+		func() bool {
152
+			root := os.Getenv("DOCKER_REMAP_ROOT")
153
+			if root != "" {
154
+				return true
155
+			}
156
+			return false
157
+		},
158
+		"Test cannot be run when remapping root",
159
+	}
150 160
 )
151 161
 
152 162
 // testRequires checks if the environment satisfies the requirements