зеркало из https://github.com/microsoft/docker.git
Merge pull request #19431 from WeiZhang555/19422-default-network
bugfix: prevent creating network 'default'
This commit is contained in:
Коммит
42ee908b3f
|
@ -277,6 +277,24 @@ func (s *DockerNetworkSuite) TestDockerNetworkLsDefault(c *check.C) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *check.C) {
|
||||
predefined := []string{"bridge", "host", "none", "default"}
|
||||
for _, net := range predefined {
|
||||
// predefined networks can't be created again
|
||||
out, _, err := dockerCmdWithError("network", "create", net)
|
||||
c.Assert(err, checker.NotNil, check.Commentf("%v", out))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkRmPredefined(c *check.C) {
|
||||
predefined := []string{"bridge", "host", "none", "default"}
|
||||
for _, net := range predefined {
|
||||
// predefined networks can't be removed
|
||||
out, _, err := dockerCmdWithError("network", "rm", net)
|
||||
c.Assert(err, checker.NotNil, check.Commentf("%v", out))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *check.C) {
|
||||
out, _ := dockerCmd(c, "network", "create", "dev")
|
||||
defer func() {
|
||||
|
|
|
@ -19,7 +19,7 @@ func DefaultDaemonNetworkMode() container.NetworkMode {
|
|||
// IsPreDefinedNetwork indicates if a network is predefined by the daemon
|
||||
func IsPreDefinedNetwork(network string) bool {
|
||||
n := container.NetworkMode(network)
|
||||
return n.IsBridge() || n.IsHost() || n.IsNone()
|
||||
return n.IsBridge() || n.IsHost() || n.IsNone() || n.IsDefault()
|
||||
}
|
||||
|
||||
// ValidateNetMode ensures that the various combinations of requested
|
||||
|
|
Загрузка…
Ссылка в новой задаче