mirror of
https://github.com/moby/moby.git
synced 2025-10-24 09:13:09 +03:00
Support container disconnect for non-existing network
There are cases such as migrating from classic overlay network to the swarm-mode networking (without kv-store), such a mechanism to allow disconnecting a container even when a network isnt available will be useful. Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
@@ -1274,6 +1274,22 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetwork(c *check.C) {
|
||||
dockerCmd(c, "network", "create", "test")
|
||||
dockerCmd(c, "run", "--net=test", "-d", "--name=foo", "busybox", "top")
|
||||
networks := inspectField(c, "foo", "NetworkSettings.Networks")
|
||||
c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
||||
|
||||
// Stop container and remove network
|
||||
dockerCmd(c, "stop", "foo")
|
||||
dockerCmd(c, "network", "rm", "test")
|
||||
|
||||
// Test disconnecting stopped container from nonexisting network
|
||||
dockerCmd(c, "network", "disconnect", "-f", "test", "foo")
|
||||
networks = inspectField(c, "foo", "NetworkSettings.Networks")
|
||||
c.Assert(networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *check.C) {
|
||||
// create two networks
|
||||
dockerCmd(c, "network", "create", "--ipv6", "--subnet=172.28.0.0/16", "--subnet=2001:db8:1234::/64", "n0")
|
||||
|
||||
Reference in New Issue
Block a user