2014-04-14 12:43:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-12-30 18:23:00 +01:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2017-03-23 18:35:22 +01:00
|
|
|
"github.com/docker/docker/integration-cli/cli/build"
|
2015-04-18 09:46:47 -07:00
|
|
|
"github.com/go-check/check"
|
2014-04-14 12:43:01 +00:00
|
|
|
)
|
|
|
|
|
2015-04-18 09:46:47 -07:00
|
|
|
func (s *DockerSuite) TestRmContainerOrphaning(c *check.C) {
|
2014-08-05 19:11:09 -04:00
|
|
|
dockerfile1 := `FROM busybox:latest
|
2016-02-02 18:39:24 -08:00
|
|
|
ENTRYPOINT ["true"]`
|
2014-08-05 19:11:09 -04:00
|
|
|
img := "test-container-orphaning"
|
|
|
|
dockerfile2 := `FROM busybox:latest
|
2016-02-02 18:39:24 -08:00
|
|
|
ENTRYPOINT ["true"]
|
2014-08-05 19:11:09 -04:00
|
|
|
MAINTAINER Integration Tests`
|
|
|
|
|
|
|
|
// build first dockerfile
|
2017-03-23 18:35:22 +01:00
|
|
|
buildImageSuccessfully(c, img, build.WithDockerfile(dockerfile1))
|
2017-01-16 11:30:14 +01:00
|
|
|
img1 := getIDByName(c, img)
|
2014-08-05 19:11:09 -04:00
|
|
|
// run container on first image
|
2015-10-19 10:42:56 +08:00
|
|
|
dockerCmd(c, "run", img)
|
2014-08-05 19:11:09 -04:00
|
|
|
// rebuild dockerfile with a small addition at the end
|
2017-03-23 18:35:22 +01:00
|
|
|
buildImageSuccessfully(c, img, build.WithDockerfile(dockerfile2))
|
2015-11-26 09:57:20 +08:00
|
|
|
// try to remove the image, should not error out.
|
2015-10-19 10:42:56 +08:00
|
|
|
out, _, err := dockerCmdWithError("rmi", img)
|
2015-11-26 09:57:20 +08:00
|
|
|
c.Assert(err, check.IsNil, check.Commentf("Expected to removing the image, but failed: %s", out))
|
2015-07-15 04:15:00 +08:00
|
|
|
|
2014-08-05 19:11:09 -04:00
|
|
|
// check if we deleted the first image
|
2015-10-19 10:42:56 +08:00
|
|
|
out, _ = dockerCmd(c, "images", "-q", "--no-trunc")
|
|
|
|
c.Assert(out, checker.Contains, img1, check.Commentf("Orphaned container (could not find %q in docker images): %s", img1, out))
|
|
|
|
|
2014-08-05 19:11:09 -04:00
|
|
|
}
|