docker_cli_rm_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. package main
  2. import (
  3. "github.com/docker/docker/integration-cli/checker"
  4. "github.com/docker/docker/integration-cli/cli/build"
  5. "github.com/go-check/check"
  6. )
  7. func (s *DockerSuite) TestRmContainerOrphaning(c *check.C) {
  8. dockerfile1 := `FROM busybox:latest
  9. ENTRYPOINT ["true"]`
  10. img := "test-container-orphaning"
  11. dockerfile2 := `FROM busybox:latest
  12. ENTRYPOINT ["true"]
  13. MAINTAINER Integration Tests`
  14. // build first dockerfile
  15. buildImageSuccessfully(c, img, build.WithDockerfile(dockerfile1))
  16. img1 := getIDByName(c, img)
  17. // run container on first image
  18. dockerCmd(c, "run", img)
  19. // rebuild dockerfile with a small addition at the end
  20. buildImageSuccessfully(c, img, build.WithDockerfile(dockerfile2))
  21. // try to remove the image, should not error out.
  22. out, _, err := dockerCmdWithError("rmi", img)
  23. c.Assert(err, check.IsNil, check.Commentf("Expected to removing the image, but failed: %s", out))
  24. // check if we deleted the first image
  25. out, _ = dockerCmd(c, "images", "-q", "--no-trunc")
  26. c.Assert(out, checker.Contains, img1, check.Commentf("Orphaned container (could not find %q in docker images): %s", img1, out))
  27. }