make docker pull only the latest tag by default
| ... | ... |
@@ -1192,7 +1192,7 @@ func (cli *DockerCli) CmdPush(args ...string) error {
|
| 1192 | 1192 |
|
| 1193 | 1193 |
func (cli *DockerCli) CmdPull(args ...string) error {
|
| 1194 | 1194 |
cmd := cli.Subcmd("pull", "NAME[:TAG]", "Pull an image or a repository from the registry")
|
| 1195 |
- tag := cmd.String([]string{"#t", "#-tag"}, "", "Download tagged image in a repository")
|
|
| 1195 |
+ allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository")
|
|
| 1196 | 1196 |
if err := cmd.Parse(args); err != nil {
|
| 1197 | 1197 |
return nil |
| 1198 | 1198 |
} |
| ... | ... |
@@ -1202,19 +1202,22 @@ func (cli *DockerCli) CmdPull(args ...string) error {
|
| 1202 | 1202 |
return nil |
| 1203 | 1203 |
} |
| 1204 | 1204 |
var ( |
| 1205 |
- v = url.Values{}
|
|
| 1206 |
- remote = cmd.Arg(0) |
|
| 1205 |
+ v = url.Values{}
|
|
| 1206 |
+ remote = cmd.Arg(0) |
|
| 1207 |
+ newRemote = remote |
|
| 1207 | 1208 |
) |
| 1208 |
- |
|
| 1209 |
- v.Set("fromImage", remote)
|
|
| 1210 |
- |
|
| 1211 |
- if *tag == "" {
|
|
| 1212 |
- v.Set("tag", *tag)
|
|
| 1209 |
+ taglessRemote, tag := parsers.ParseRepositoryTag(remote) |
|
| 1210 |
+ if tag == "" && !*allTags {
|
|
| 1211 |
+ newRemote = taglessRemote + ":latest" |
|
| 1212 |
+ } |
|
| 1213 |
+ if tag != "" && *allTags {
|
|
| 1214 |
+ return fmt.Errorf("tag can't be used with --all-tags/-a")
|
|
| 1213 | 1215 |
} |
| 1214 | 1216 |
|
| 1215 |
- remote, _ = parsers.ParseRepositoryTag(remote) |
|
| 1217 |
+ v.Set("fromImage", newRemote)
|
|
| 1218 |
+ |
|
| 1216 | 1219 |
// Resolve the Repository name from fqn to hostname + name |
| 1217 |
- hostname, _, err := registry.ResolveRepositoryName(remote) |
|
| 1220 |
+ hostname, _, err := registry.ResolveRepositoryName(taglessRemote) |
|
| 1218 | 1221 |
if err != nil {
|
| 1219 | 1222 |
return err |
| 1220 | 1223 |
} |
| ... | ... |
@@ -266,6 +266,9 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecomp |
| 266 | 266 |
|
| 267 | 267 |
func (b *Builder) pullImage(name string) (*imagepkg.Image, error) {
|
| 268 | 268 |
remote, tag := parsers.ParseRepositoryTag(name) |
| 269 |
+ if tag == "" {
|
|
| 270 |
+ tag = "latest" |
|
| 271 |
+ } |
|
| 269 | 272 |
pullRegistryAuth := b.AuthConfig |
| 270 | 273 |
if len(b.AuthConfigFile.Configs) > 0 {
|
| 271 | 274 |
// The request came with a full auth config file, we prefer to use that |
| ... | ... |
@@ -6,6 +6,7 @@ docker-pull - Pull an image or a repository from the registry |
| 6 | 6 |
|
| 7 | 7 |
# SYNOPSIS |
| 8 | 8 |
**docker pull** |
| 9 |
+[**-a**|**--all-tags**[=*false*]] |
|
| 9 | 10 |
NAME[:TAG] |
| 10 | 11 |
|
| 11 | 12 |
# DESCRIPTION |
| ... | ... |
@@ -16,7 +17,8 @@ images for that repository name are pulled down including any tags. |
| 16 | 16 |
It is also possible to specify a non-default registry to pull from. |
| 17 | 17 |
|
| 18 | 18 |
# OPTIONS |
| 19 |
-There are no available options. |
|
| 19 |
+**-a**, **--all-tags**=*true*|*false* |
|
| 20 |
+ Download all tagged images in the repository. The default is *false*. |
|
| 20 | 21 |
|
| 21 | 22 |
# EXAMPLES |
| 22 | 23 |
|
| ... | ... |
@@ -53,3 +55,4 @@ There are no available options. |
| 53 | 53 |
April 2014, Originally compiled by William Henry (whenry at redhat dot com) |
| 54 | 54 |
based on docker.com source material and internal work. |
| 55 | 55 |
June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> |
| 56 |
+August 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> |
| ... | ... |
@@ -852,6 +852,8 @@ This shows all the containers that have exited with status of '0' |
| 852 | 852 |
|
| 853 | 853 |
Pull an image or a repository from the registry |
| 854 | 854 |
|
| 855 |
+ -a, --all-tags=false Download all tagged images in the repository |
|
| 856 |
+ |
|
| 855 | 857 |
Most of your images will be created on top of a base image from the |
| 856 | 858 |
[Docker Hub](https://hub.docker.com) registry. |
| 857 | 859 |
|
| ... | ... |
@@ -867,11 +869,13 @@ To download a particular image, or set of images (i.e., a repository), |
| 867 | 867 |
use `docker pull`: |
| 868 | 868 |
|
| 869 | 869 |
$ docker pull debian |
| 870 |
- # will pull all the images in the debian repository |
|
| 870 |
+ # will pull only the debian:latest image and its intermediate layers |
|
| 871 | 871 |
$ docker pull debian:testing |
| 872 | 872 |
# will pull only the image named debian:testing and any intermediate layers |
| 873 |
- # it is based on. (Typically the empty `scratch` image, a MAINTAINERs layer, |
|
| 873 |
+ # it is based on. (Typically the empty `scratch` image, a MAINTAINER layer, |
|
| 874 | 874 |
# and the un-tarred base). |
| 875 |
+ $ docker pull --all-tags centos |
|
| 876 |
+ # will pull all the images from the centos repository |
|
| 875 | 877 |
$ docker pull registry.hub.docker.com/debian |
| 876 | 878 |
# manually specifies the path to the default Docker registry. This could |
| 877 | 879 |
# be replaced with the path to a local registry to pull from another source. |