From 9c08364a412a51c80e8d17ae14f92549dc543e68 Mon Sep 17 00:00:00 2001 From: unclejack Date: Wed, 27 Aug 2014 15:38:12 +0300 Subject: [PATCH 1/3] add --all-tags to pull & pull latest by default Docker-DCO-1.1-Signed-off-by: Cristian Staretu (github: unclejack) --- api/client/commands.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/api/client/commands.go b/api/client/commands.go index 4a5f2faea8..9a653426ff 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -1192,7 +1192,7 @@ func (cli *DockerCli) CmdPush(args ...string) error { func (cli *DockerCli) CmdPull(args ...string) error { cmd := cli.Subcmd("pull", "NAME[:TAG]", "Pull an image or a repository from the registry") - tag := cmd.String([]string{"#t", "#-tag"}, "", "Download tagged image in a repository") + allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository") if err := cmd.Parse(args); err != nil { return nil } @@ -1202,19 +1202,22 @@ func (cli *DockerCli) CmdPull(args ...string) error { return nil } var ( - v = url.Values{} - remote = cmd.Arg(0) + v = url.Values{} + remote = cmd.Arg(0) + newRemote = remote ) - - v.Set("fromImage", remote) - - if *tag == "" { - v.Set("tag", *tag) + taglessRemote, tag := parsers.ParseRepositoryTag(remote) + if tag == "" && !*allTags { + newRemote = taglessRemote + ":latest" + } + if tag != "" && *allTags { + return fmt.Errorf("tag can't be used with --all-tags/-a") } - remote, _ = parsers.ParseRepositoryTag(remote) + v.Set("fromImage", newRemote) + // Resolve the Repository name from fqn to hostname + name - hostname, _, err := registry.ResolveRepositoryName(remote) + hostname, _, err := registry.ResolveRepositoryName(taglessRemote) if err != nil { return err } From 82b0c3e59ca12dd87bf2a9d88a63ff66e7d29fb4 Mon Sep 17 00:00:00 2001 From: SvenDowideit Date: Fri, 29 Aug 2014 10:16:40 +1000 Subject: [PATCH 2/3] add a little documentation for docker pull Docker-DCO-1.1-Signed-off-by: SvenDowideit (github: SvenDowideit) --- docs/man/docker-pull.1.md | 5 ++++- docs/sources/reference/commandline/cli.md | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/man/docker-pull.1.md b/docs/man/docker-pull.1.md index 465c97aadd..2adda7821e 100644 --- a/docs/man/docker-pull.1.md +++ b/docs/man/docker-pull.1.md @@ -6,6 +6,7 @@ docker-pull - Pull an image or a repository from the registry # SYNOPSIS **docker pull** +[**-a**|**--all-tags**[=*false*]] NAME[:TAG] # DESCRIPTION @@ -16,7 +17,8 @@ images for that repository name are pulled down including any tags. It is also possible to specify a non-default registry to pull from. # OPTIONS -There are no available options. +**-a**, **--all-tags**=*true*|*false* + Download all tagged images in the repository. The default is *false*. # EXAMPLES @@ -53,3 +55,4 @@ There are no available options. April 2014, Originally compiled by William Henry (whenry at redhat dot com) based on docker.com source material and internal work. June 2014, updated by Sven Dowideit +August 2014, updated by Sven Dowideit diff --git a/docs/sources/reference/commandline/cli.md b/docs/sources/reference/commandline/cli.md index 9c313b0c78..c8edc11d0a 100644 --- a/docs/sources/reference/commandline/cli.md +++ b/docs/sources/reference/commandline/cli.md @@ -852,6 +852,8 @@ This shows all the containers that have exited with status of '0' Pull an image or a repository from the registry + -a, --all-tags=false Download all tagged images in the repository + Most of your images will be created on top of a base image from the [Docker Hub](https://hub.docker.com) registry. @@ -867,11 +869,13 @@ To download a particular image, or set of images (i.e., a repository), use `docker pull`: $ docker pull debian - # will pull all the images in the debian repository + # will pull only the debian:latest image and its intermediate layers $ docker pull debian:testing # will pull only the image named debian:testing and any intermediate layers - # it is based on. (Typically the empty `scratch` image, a MAINTAINERs layer, + # it is based on. (Typically the empty `scratch` image, a MAINTAINER layer, # and the un-tarred base). + $ docker pull --all-tags centos + # will pull all the images from the centos repository $ docker pull registry.hub.docker.com/debian # manually specifies the path to the default Docker registry. This could # be replaced with the path to a local registry to pull from another source. From 6ba5d67a51d96e6c2923227c99ee049bbf8e5f50 Mon Sep 17 00:00:00 2001 From: unclejack Date: Wed, 3 Sep 2014 18:27:25 +0300 Subject: [PATCH 3/3] docker build: pull just latest if tag uspecified Docker-DCO-1.1-Signed-off-by: Cristian Staretu (github: unclejack) --- builder/internals.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builder/internals.go b/builder/internals.go index 62fff0701b..c61e5114a6 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -271,6 +271,9 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecomp func (b *Builder) pullImage(name string) (*imagepkg.Image, error) { remote, tag := parsers.ParseRepositoryTag(name) + if tag == "" { + tag = "latest" + } pullRegistryAuth := b.AuthConfig if len(b.AuthConfigFile.Configs) > 0 { // The request came with a full auth config file, we prefer to use that