diff --git a/api/client/pull.go b/api/client/pull.go index 50d4ff7228..78de9c9791 100644 --- a/api/client/pull.go +++ b/api/client/pull.go @@ -63,10 +63,10 @@ func (cli *DockerCli) CmdPull(args ...string) error { return cli.trustedPull(repoInfo, registryRef, authConfig, requestPrivilege) } - return cli.imagePullPrivileged(authConfig, distributionRef.String(), requestPrivilege) + return cli.imagePullPrivileged(authConfig, distributionRef.String(), requestPrivilege, *allTags) } -func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) error { +func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error { encodedAuth, err := encodeAuthToBase64(authConfig) if err != nil { @@ -75,6 +75,7 @@ func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref strin options := types.ImagePullOptions{ RegistryAuth: encodedAuth, PrivilegeFunc: requestPrivilege, + All: all, } responseBody, err := cli.client.ImagePull(context.Background(), ref, options) diff --git a/api/client/trust.go b/api/client/trust.go index 4f1e4131f4..37d5e51bfa 100644 --- a/api/client/trust.go +++ b/api/client/trust.go @@ -377,7 +377,7 @@ func (cli *DockerCli) trustedPull(repoInfo *registry.RepositoryInfo, ref registr if err != nil { return err } - if err := cli.imagePullPrivileged(authConfig, ref.String(), requestPrivilege); err != nil { + if err := cli.imagePullPrivileged(authConfig, ref.String(), requestPrivilege, false); err != nil { return err } diff --git a/integration-cli/docker_cli_pull_test.go b/integration-cli/docker_cli_pull_test.go index c9f4ef195f..3f91ac1d01 100644 --- a/integration-cli/docker_cli_pull_test.go +++ b/integration-cli/docker_cli_pull_test.go @@ -237,6 +237,20 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) { c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("busybox:latest was changed after pulling all tags")) } +// TestRunImplicitPullWithNoTagOnlyPullDefaultTag should pull implicitely only the default tag (latest) +func (s *DockerHubPullSuite) TestRunImplicitPullWithNoTagOnlyPullDefaultTag(c *check.C) { + // run with an image we don't have + testRequires(c, DaemonIsLinux) + out := s.Cmd(c, "run", "busybox") + + c.Assert(out, checker.Contains, "Unable to find image 'busybox:latest' locally") + + // There should be only one line for busybox, the one with busybox:latest + outImageCmd := s.Cmd(c, "images", "busybox") + splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n") + c.Assert(splitOutImageCmd, checker.HasLen, 2) +} + // TestPullClientDisconnect kills the client during a pull operation and verifies that the operation // gets cancelled. //