Fix docker start error with renamed container

This fix tries to fix the issue raised in #23716 where `docker start`
causes an error of `No such container:` if the container has been
renamed before `docker start` returns.

The issue is that `docker start` use container name passed at the
beginning to check for exit code at the end of the `docker start`.

This fix addresses the issue by always use container's `ID` to get
the information during `docker start`.

Additional integration tests have been added to cover this fix.

This fix fixes #23716.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 6e86733b47faf0d7629751987346022544b65cb7
Component: engine
This commit is contained in:
Yong Tang
2016-06-18 16:43:30 -07:00
parent 78a01ebf61
commit b8c843c318
2 changed files with 20 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"os/exec"
"strings"
"time"
@ -171,3 +172,16 @@ func (s *DockerSuite) TestStartAttachMultipleContainers(c *check.C) {
c.Assert(out, checker.Equals, expected)
}
}
// Test case for #23716
func (s *DockerSuite) TestStartAttachWithRename(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "-t", "--name", "before", "busybox")
go func() {
c.Assert(waitRun("before"), checker.IsNil)
dockerCmd(c, "rename", "before", "after")
dockerCmd(c, "stop", "--time=2", "after")
}()
_, stderr, _, _ := runCommandWithStdoutStderr(exec.Command(dockerBinary, "start", "-a", "before"))
c.Assert(stderr, checker.Not(checker.Contains), "No such container")
}