|
@@ -294,85 +294,6 @@ func (s *DockerSuite) TestRunLinksContainerWithContainerId(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestRunLinkToContainerNetMode(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "--name", "test", "-d", "busybox", "top")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--name", "parent", "-d", "--net=container:test", "busybox", "top")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
- cmd = exec.Command(dockerBinary, "run", "-d", "--link=parent:parent", "busybox", "top")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--name", "child", "-d", "--net=container:parent", "busybox", "top")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
- cmd = exec.Command(dockerBinary, "run", "-d", "--link=child:child", "busybox", "top")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func (s *DockerSuite) TestRunContainerNetModeWithDnsMacHosts(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "-d", "--name", "parent", "busybox", "top")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--dns", "1.2.3.4", "--net=container:parent", "busybox")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "Conflicting options: --dns and the network mode") {
|
|
|
- c.Fatalf("run --net=container with --dns should error out")
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--mac-address", "92:d0:c6:0a:29:33", "--net=container:parent", "busybox")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "--mac-address and the network mode") {
|
|
|
- c.Fatalf("run --net=container with --mac-address should error out")
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--add-host", "test:192.168.2.109", "--net=container:parent", "busybox")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "--add-host and the network mode") {
|
|
|
- c.Fatalf("run --net=container with --add-host should error out")
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-func (s *DockerSuite) TestRunModeNetContainerHostname(c *check.C) {
|
|
|
- testRequires(c, ExecSupport)
|
|
|
- cmd := exec.Command(dockerBinary, "run", "-i", "-d", "--name", "parent", "busybox", "top")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
- cmd = exec.Command(dockerBinary, "exec", "parent", "cat", "/etc/hostname")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to exec command: %v, output: %q", err, out)
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--net=container:parent", "busybox", "cat", "/etc/hostname")
|
|
|
- out1, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out1)
|
|
|
- }
|
|
|
- if out1 != out {
|
|
|
- c.Fatal("containers with shared net namespace should have same hostname")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// Regression test for #4979
|
|
|
func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) {
|
|
|
runCmd := exec.Command(dockerBinary, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file")
|
|
@@ -853,14 +774,6 @@ func (s *DockerSuite) TestRunContainerNetwork(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Issue #4681
|
|
|
-func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ping", "-c", "1", "127.0.0.1")
|
|
|
- if _, err := runCommand(cmd); err != nil {
|
|
|
- c.Fatal(err)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *check.C) {
|
|
|
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", "linked", "busybox", "true"))
|
|
|
if err != nil {
|
|
@@ -873,33 +786,6 @@ func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ip", "-o", "-4", "a", "show", "up")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatal(err, out)
|
|
|
- }
|
|
|
-
|
|
|
- var (
|
|
|
- count = 0
|
|
|
- parts = strings.Split(out, "\n")
|
|
|
- )
|
|
|
-
|
|
|
- for _, l := range parts {
|
|
|
- if l != "" {
|
|
|
- count++
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if count != 1 {
|
|
|
- c.Fatalf("Wrong interface count in container %d", count)
|
|
|
- }
|
|
|
-
|
|
|
- if !strings.HasPrefix(out, "1: lo") {
|
|
|
- c.Fatalf("Wrong interface in test container: expected [1: lo], got %s", out)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// #7851 hostname outside container shows FQDN, inside only shortname
|
|
|
// For testing purposes it is not required to set host's hostname directly
|
|
|
// and use "--net=host" (as the original issue submitter did), as the same
|
|
@@ -2103,20 +1989,6 @@ func (s *DockerSuite) TestRunCidFileCheckIDLength(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "-d", "--net=none", "busybox", "top")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatal(err)
|
|
|
- }
|
|
|
- id := strings.TrimSpace(out)
|
|
|
- res, err := inspectField(id, "NetworkSettings.IPAddress")
|
|
|
- c.Assert(err, check.IsNil)
|
|
|
- if res != "" {
|
|
|
- c.Fatalf("For 'none' mode network must not be initialized, but container got IP: %s", res)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func (s *DockerSuite) TestRunSetMacAddress(c *check.C) {
|
|
|
mac := "12:34:56:78:9a:bc"
|
|
|
|
|
@@ -2616,14 +2488,6 @@ func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestContainerNetworkModeToSelf(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "--name=me", "--net=container:me", "busybox", "true")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "cannot join own network") {
|
|
|
- c.Fatalf("using container net mode to self should result in an error")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func (s *DockerSuite) TestRunModePidHost(c *check.C) {
|
|
|
testRequires(c, NativeExecDriver, SameHostDaemon)
|
|
|
|
|
@@ -2882,26 +2746,6 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestRunOOMExitCode(c *check.C) {
|
|
|
- testRequires(c, OomControl)
|
|
|
- errChan := make(chan error)
|
|
|
- go func() {
|
|
|
- defer close(errChan)
|
|
|
- runCmd := exec.Command(dockerBinary, "run", "-m", "4MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
|
|
|
- out, exitCode, _ := runCommandWithOutput(runCmd)
|
|
|
- if expected := 137; exitCode != expected {
|
|
|
- errChan <- fmt.Errorf("wrong exit code for OOM container: expected %d, got %d (output: %q)", expected, exitCode, out)
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- select {
|
|
|
- case err := <-errChan:
|
|
|
- c.Assert(err, check.IsNil)
|
|
|
- case <-time.After(30 * time.Second):
|
|
|
- c.Fatal("Timeout waiting for container to die on OOM")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *check.C) {
|
|
|
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "test", "busybox", "top")
|
|
|
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
|
@@ -3141,13 +2985,6 @@ func (s *DockerSuite) TestMountIntoSys(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestTwoContainersInNetHost(c *check.C) {
|
|
|
- dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
|
|
|
- dockerCmd(c, "run", "-d", "--net=host", "--name=second", "busybox", "top")
|
|
|
- dockerCmd(c, "stop", "first")
|
|
|
- dockerCmd(c, "stop", "second")
|
|
|
-}
|
|
|
-
|
|
|
func (s *DockerSuite) TestRunUnshareProc(c *check.C) {
|
|
|
testRequires(c, Apparmor, NativeExecDriver)
|
|
|
|
|
@@ -3195,33 +3032,6 @@ func (s *DockerSuite) TestDevicePermissions(c *check.C) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *check.C) {
|
|
|
- cmd := exec.Command(dockerBinary, "run", "-d", "--name", "parent", "busybox", "top")
|
|
|
- out, _, err := runCommandWithOutput(cmd)
|
|
|
- if err != nil {
|
|
|
- c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "-p", "5000:5000", "--net=container:parent", "busybox")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "Conflicting options: -p, -P, --publish-all, --publish and the network mode (--net)") {
|
|
|
- c.Fatalf("run --net=container with -p should error out")
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "-P", "--net=container:parent", "busybox")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "Conflicting options: -p, -P, --publish-all, --publish and the network mode (--net)") {
|
|
|
- c.Fatalf("run --net=container with -P should error out")
|
|
|
- }
|
|
|
-
|
|
|
- cmd = exec.Command(dockerBinary, "run", "--expose", "5000", "--net=container:parent", "busybox")
|
|
|
- out, _, err = runCommandWithOutput(cmd)
|
|
|
- if err == nil || !strings.Contains(out, "Conflicting options: --expose and the network mode (--expose)") {
|
|
|
- c.Fatalf("run --net=container with --expose should error out")
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
func (s *DockerSuite) TestRunCapAddCHOWN(c *check.C) {
|
|
|
cmd := exec.Command(dockerBinary, "run", "--cap-drop=ALL", "--cap-add=CHOWN", "busybox", "sh", "-c", "adduser -D -H newuser && chown newuser /home && echo ok")
|
|
|
out, _, err := runCommandWithOutput(cmd)
|