Merge pull request #19431 from WeiZhang555/19422-default-network

bugfix: prevent creating network 'default'
This commit is contained in:
Lei Jitang 2016-01-19 14:18:20 +08:00
Родитель b6be645197 31dae442c8
Коммит 42ee908b3f
2 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -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