Skip to content

Commit

Permalink
dockerbuild pulls all images rather than :latest
Browse files Browse the repository at this point in the history
A FROM foo/bar in a Dockerfile will result in docker pulling all tags in
foo/bar, rather than just foo/bar:latest.  Default to :latest in the
dockerbuilder.
  • Loading branch information
smarterclayton committed Jun 1, 2016
1 parent 504ea97 commit 020d51f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/util/docker/dockerfile/builder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,12 @@ func (e *ClientExecutor) LoadImage(from string) (*docker.Image, error) {
return nil, docker.ErrNoSuchImage
}

repository, _ := docker.ParseRepositoryTag(from)
repository, tag := docker.ParseRepositoryTag(from)
if len(tag) == 0 {
tag = "latest"
}

glog.V(4).Infof("attempting to pull %s with auth from repository %s", from, repository)
glog.V(4).Infof("attempting to pull %s with auth from repository %s:%s", from, repository, tag)

// TODO: we may want to abstract looping over multiple credentials
auth, _ := e.AuthFn(repository)
Expand All @@ -298,7 +301,7 @@ func (e *ClientExecutor) LoadImage(from string) (*docker.Image, error) {
for _, config := range auth {
// TODO: handle IDs?
// TODO: use RawJSONStream:true and handle the output nicely
if err = e.Client.PullImage(docker.PullImageOptions{Repository: from, OutputStream: e.Out}, config); err == nil {
if err = e.Client.PullImage(docker.PullImageOptions{Repository: from, OutputStream: e.Out, Tag: tag}, config); err == nil {
break
}
lastErr = err
Expand Down

0 comments on commit 020d51f

Please sign in to comment.