mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Reject multiple networks on container creation
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
@ -20,6 +20,7 @@ import (
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/engine-api/types"
|
||||
containertypes "github.com/docker/engine-api/types/container"
|
||||
networktypes "github.com/docker/engine-api/types/network"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
@ -604,6 +605,29 @@ func (s *DockerSuite) TestContainerApiCreateEmptyConfig(c *check.C) {
|
||||
c.Assert(string(b), checker.Equals, expected)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerApiCreateMultipleNetworksConfig(c *check.C) {
|
||||
// Container creation must fail if client specified configurations for more than one network
|
||||
config := map[string]interface{}{
|
||||
"Image": "busybox",
|
||||
"NetworkingConfig": networktypes.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*networktypes.EndpointSettings{
|
||||
"net1": {},
|
||||
"net2": {},
|
||||
"net3": {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
status, b, err := sockRequest("POST", "/containers/create", config)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(status, checker.Equals, http.StatusBadRequest)
|
||||
// network name order in error message is not deterministic
|
||||
c.Assert(string(b), checker.Contains, "Container cannot be connected to [")
|
||||
c.Assert(string(b), checker.Contains, "net1")
|
||||
c.Assert(string(b), checker.Contains, "net2")
|
||||
c.Assert(string(b), checker.Contains, "net3")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerApiCreateWithHostName(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
hostName := "test-host"
|
||||
|
Reference in New Issue
Block a user