Browse code

Pull all image aliases for id. Closes #8141.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)

Jessica Frazelle authored on 2014/09/24 07:58:05
Showing 3 changed files
... ...
@@ -152,7 +152,7 @@ progress of your daemonized process.
152 152
 You can detach from the container again (and leave it running) with
153 153
 `CTRL-p CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a
154 154
 SIGKILL to the container, or `CTRL-\` to get a stacktrace of the
155
-Docker client when it quits. When you detach from the container's 
155
+Docker client when it quits. When you detach from the container's
156 156
 process the exit code will be returned to the client.
157 157
 
158 158
 To stop a container, use `docker stop`.
... ...
@@ -965,10 +965,13 @@ To download a particular image, or set of images (i.e., a repository),
965 965
 use `docker pull`:
966 966
 
967 967
     $ sudo docker pull debian
968
-    # will pull only the debian:latest image and its intermediate layers 
968
+    # will pull the debian:latest image, its intermediate layers
969
+    # and any aliases of the same id
969 970
     $ sudo docker pull debian:testing
970
-    # will pull only the image named debian:testing and any intermediate layers
971
-    # it is based on. (Typically the empty `scratch` image, a MAINTAINER layer,
971
+    # will pull the image named ubuntu:trusty, ubuntu:14.04
972
+    # which is an alias of the same image
973
+    # and any intermediate layers it is based on.
974
+    # (Typically the empty `scratch` image, a MAINTAINER layer,
972 975
     # and the un-tarred base).
973 976
     $ sudo docker pull --all-tags centos
974 977
     # 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