Fix docker rename with linked containers
This fix tries to address issue raised in #23973 where the `docker rename` does not update namedIndex and linkIndex, thus resulting in failures when the linked containers are referenced later on. This fix updates the namedIndex and linkIndex during the `docker rename` and fixes the issue. An integration test has been added to cover the changes in this fix. This fix fixes #23973. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> Upstream-commit: 3f6e3a0885124a00c7f915af8f9181e6a275d828 Component: engine
This commit is contained in:
@@ -121,3 +121,15 @@ func (s *DockerSuite) TestRenameContainerWithSameName(c *check.C) {
|
||||
c.Assert(err, checker.NotNil, check.Commentf("Renaming a container with the same name should have failed"))
|
||||
c.Assert(out, checker.Contains, "Renaming a container with the same name", check.Commentf("%v", err))
|
||||
}
|
||||
|
||||
// Test case for #23973
|
||||
func (s *DockerSuite) TestRenameContainerWithLinkedContainer(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
db1, _ := dockerCmd(c, "run", "--name", "db1", "-d", "busybox", "top")
|
||||
dockerCmd(c, "run", "--name", "app1", "-d", "--link", "db1:/mysql", "busybox", "top")
|
||||
dockerCmd(c, "rename", "app1", "app2")
|
||||
out, _, err := dockerCmdWithError("inspect", "--format='{{ .Id }}'", "app2/mysql")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, strings.TrimSpace(db1))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user