|
@@ -3186,3 +3186,30 @@ func (s *DockerSuite) TestRunUnshareProc(c *check.C) {
|
|
|
c.Fatalf("unshare should have failed with permission denied, got: %s, %v", out, err)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+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")
|
|
|
+ }
|
|
|
+
|
|
|
+}
|