docker_cli_pull_local_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/go-check/check"
  5. )
  6. // TestPullImageWithAliases pulls a specific image tag and verifies that any aliases (i.e., other
  7. // tags for the same image) are not also pulled down.
  8. //
  9. // Ref: docker/docker#8141
  10. func (s *DockerRegistrySuite) TestPullImageWithAliases(c *check.C) {
  11. repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
  12. repos := []string{}
  13. for _, tag := range []string{"recent", "fresh"} {
  14. repos = append(repos, fmt.Sprintf("%v:%v", repoName, tag))
  15. }
  16. // Tag and push the same image multiple times.
  17. for _, repo := range repos {
  18. dockerCmd(c, "tag", "busybox", repo)
  19. dockerCmd(c, "push", repo)
  20. }
  21. // Clear local images store.
  22. args := append([]string{"rmi"}, repos...)
  23. dockerCmd(c, args...)
  24. // Pull a single tag and verify it doesn't bring down all aliases.
  25. dockerCmd(c, "pull", repos[0])
  26. dockerCmd(c, "inspect", repos[0])
  27. for _, repo := range repos[1:] {
  28. if _, _, err := dockerCmdWithError("inspect", repo); err == nil {
  29. c.Fatalf("Image %v shouldn't have been pulled down", repo)
  30. }
  31. }
  32. }