Browse Source

Pull all image aliases for id. Closes #8141.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
Jessica Frazelle 10 years ago
parent
commit
7d74be162c

+ 7 - 4
docs/sources/reference/commandline/cli.md

@@ -152,7 +152,7 @@ progress of your daemonized process.
 You can detach from the container again (and leave it running) with
 You can detach from the container again (and leave it running) with
 `CTRL-p CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a
 `CTRL-p CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a
 SIGKILL to the container, or `CTRL-\` to get a stacktrace of the
 SIGKILL to the container, or `CTRL-\` to get a stacktrace of the
-Docker client when it quits. When you detach from the container's 
+Docker client when it quits. When you detach from the container's
 process the exit code will be returned to the client.
 process the exit code will be returned to the client.
 
 
 To stop a container, use `docker stop`.
 To stop a container, use `docker stop`.
@@ -965,10 +965,13 @@ To download a particular image, or set of images (i.e., a repository),
 use `docker pull`:
 use `docker pull`:
 
 
     $ sudo docker pull debian
     $ sudo docker pull debian
-    # will pull only the debian:latest image and its intermediate layers 
+    # will pull the debian:latest image, its intermediate layers
+    # and any aliases of the same id
     $ sudo docker pull debian:testing
     $ sudo 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 MAINTAINER layer,
+    # will pull the image named ubuntu:trusty, ubuntu:14.04
+    # which is an alias of the same image
+    # and any intermediate layers it is based on.
+    # (Typically the empty `scratch` image, a MAINTAINER layer,
     # and the un-tarred base).
     # and the un-tarred base).
     $ sudo docker pull --all-tags centos
     $ sudo docker pull --all-tags centos
     # will pull all the images from the centos repository
     # will pull all the images from the centos repository

+ 3 - 1
graph/pull.go

@@ -106,6 +106,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, localName,
 
 
 	log.Debugf("Registering tags")
 	log.Debugf("Registering tags")
 	// If no tag has been specified, pull them all
 	// If no tag has been specified, pull them all
+	var imageId string
 	if askedTag == "" {
 	if askedTag == "" {
 		for tag, id := range tagsList {
 		for tag, id := range tagsList {
 			repoData.ImgList[id].Tag = tag
 			repoData.ImgList[id].Tag = tag
@@ -116,6 +117,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, localName,
 		if !exists {
 		if !exists {
 			return fmt.Errorf("Tag %s not found in repository %s", askedTag, localName)
 			return fmt.Errorf("Tag %s not found in repository %s", askedTag, localName)
 		}
 		}
+		imageId = id
 		repoData.ImgList[id].Tag = askedTag
 		repoData.ImgList[id].Tag = askedTag
 	}
 	}
 
 
@@ -217,7 +219,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, localName,
 
 
 	}
 	}
 	for tag, id := range tagsList {
 	for tag, id := range tagsList {
-		if askedTag != "" && tag != askedTag {
+		if askedTag != "" && id != imageId {
 			continue
 			continue
 		}
 		}
 		if err := s.Set(localName, tag, id, true); err != nil {
 		if err := s.Set(localName, tag, id, true); err != nil {

+ 4 - 2
integration-cli/docker_cli_pull_test.go

@@ -6,6 +6,8 @@ import (
 	"testing"
 	"testing"
 )
 )
 
 
+// FIXME: we need a test for pulling all aliases for an image (issue #8141)
+
 // pulling an image from the central registry should work
 // pulling an image from the central registry should work
 func TestPullImageFromCentralRegistry(t *testing.T) {
 func TestPullImageFromCentralRegistry(t *testing.T) {
 	pullCmd := exec.Command(dockerBinary, "pull", "scratch")
 	pullCmd := exec.Command(dockerBinary, "pull", "scratch")
@@ -13,9 +15,9 @@ func TestPullImageFromCentralRegistry(t *testing.T) {
 	errorOut(err, t, fmt.Sprintf("%s %s", out, err))
 	errorOut(err, t, fmt.Sprintf("%s %s", out, err))
 
 
 	if err != nil || exitCode != 0 {
 	if err != nil || exitCode != 0 {
-		t.Fatal("pulling the busybox image from the registry has failed")
+		t.Fatal("pulling the scratch image from the registry has failed")
 	}
 	}
-	logDone("pull - pull busybox")
+	logDone("pull - pull scratch")
 }
 }
 
 
 // pulling a non-existing image from the central registry should return a non-zero exit code
 // pulling a non-existing image from the central registry should return a non-zero exit code