|
@@ -3177,3 +3177,30 @@ func (s *DockerSuite) TestDevicePermissions(c *check.C) {
|
|
|
c.Fatalf("output should begin with %q, got %q", permissions, out)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+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")
|
|
|
+ }
|
|
|
+
|
|
|
+}
|