Browse code

Merge pull request #8193 from jfrazelle/8141-pull-all-image-aliases-for-id

Pull all image aliases for id

Tibor Vass authored on 2014/09/26 04:22:46
Showing 3 changed files
... ...
@@ -156,7 +156,7 @@ progress of your daemonized process.
156 156
 You can detach from the container again (and leave it running) with
157 157
 `CTRL-p CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a
158 158
 SIGKILL to the container, or `CTRL-\` to get a stacktrace of the
159
-Docker client when it quits. When you detach from the container's 
159
+Docker client when it quits. When you detach from the container's
160 160
 process the exit code will be returned to the client.
161 161
 
162 162
 To stop a container, use `docker stop`.
... ...
@@ -974,10 +974,13 @@ To download a particular image, or set of images (i.e., a repository),
974 974
 use `docker pull`:
975 975
 
976 976
     $ sudo docker pull debian
977
-    # will pull only the debian:latest image and its intermediate layers 
977
+    # will pull the debian:latest image, its intermediate layers
978
+    # and any aliases of the same id
978 979
     $ sudo docker pull debian:testing
979
-    # will pull only the image named debian:testing and any intermediate layers
980
-    # it is based on. (Typically the empty `scratch` image, a MAINTAINER layer,
980
+    # will pull the image named ubuntu:trusty, ubuntu:14.04
981
+    # which is an alias of the same image
982
+    # and any intermediate layers it is based on.
983
+    # (Typically the empty `scratch` image, a MAINTAINER layer,
981 984
     # and the un-tarred base).
982 985
     $ sudo docker pull --all-tags centos
983 986
     # will pull all the images from the centos repository
... ...
@@ -106,6 +106,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, localName,
106 106
 
107 107
 	log.Debugf("Registering tags")
108 108
 	// If no tag has been specified, pull them all
109
+	var imageId string
109 110
 	if askedTag == "" {
110 111
 		for tag, id := range tagsList {
111 112
 			repoData.ImgList[id].Tag = tag
... ...
@@ -116,6 +117,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, localName,
116 116
 		if !exists {
117 117
 			return fmt.Errorf("Tag %s not found in repository %s", askedTag, localName)
118 118
 		}
119
+		imageId = id
119 120
 		repoData.ImgList[id].Tag = askedTag
120 121
 	}
121 122
 
... ...
@@ -217,7 +219,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, localName,
217 217
 
218 218
 	}
219 219
 	for tag, id := range tagsList {
220
-		if askedTag != "" && tag != askedTag {
220
+		if askedTag != "" && id != imageId {
221 221
 			continue
222 222
 		}
223 223
 		if err := s.Set(localName, tag, id, true); err != nil {
... ...
@@ -6,6 +6,8 @@ import (
6 6
 	"testing"
7 7
 )
8 8
 
9
+// FIXME: we need a test for pulling all aliases for an image (issue #8141)
10
+
9 11
 // pulling an image from the central registry should work
10 12
 func TestPullImageFromCentralRegistry(t *testing.T) {
11 13
 	pullCmd := exec.Command(dockerBinary, "pull", "scratch")
... ...
@@ -13,9 +15,9 @@ func TestPullImageFromCentralRegistry(t *testing.T) {
13 13
 	errorOut(err, t, fmt.Sprintf("%s %s", out, err))
14 14
 
15 15
 	if err != nil || exitCode != 0 {
16
-		t.Fatal("pulling the busybox image from the registry has failed")
16
+		t.Fatal("pulling the scratch image from the registry has failed")
17 17
 	}
18
-	logDone("pull - pull busybox")
18
+	logDone("pull - pull scratch")
19 19
 }
20 20
 
21 21
 // pulling a non-existing image from the central registry should return a non-zero exit code