Merge pull request #28899 from aaronlehmann/dont-pull-image-id

Don't resolve or pull images referenced by ID
This commit is contained in:
Vincent Demeester 2016-11-30 10:08:43 +01:00 committed by GitHub
commit 768f4ce02b
2 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import (
"time"
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/digest"
distreference "github.com/docker/distribution/reference"
apierrors "github.com/docker/docker/api/errors"
apitypes "github.com/docker/docker/api/types"
@ -1021,6 +1022,9 @@ func (c *Cluster) GetServices(options apitypes.ServiceListOptions) ([]types.Serv
// TODO(nishanttotla): After the packages converge, the function must
// convert distreference.Named -> distreference.Canonical, and the logic simplified.
func (c *Cluster) imageWithDigestString(ctx context.Context, image string, authConfig *apitypes.AuthConfig) (string, error) {
if _, err := digest.ParseDigest(image); err == nil {
return "", errors.New("image reference is an image ID")
}
ref, err := distreference.ParseNamed(image)
if err != nil {
return "", err

View File

@ -10,6 +10,7 @@ import (
"time"
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/digest"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
@ -53,6 +54,11 @@ func newContainerAdapter(b executorpkg.Backend, task *api.Task, secrets exec.Sec
func (c *containerAdapter) pullImage(ctx context.Context) error {
spec := c.container.spec()
// Skip pulling if the image is referenced by image ID.
if _, err := digest.ParseDigest(spec.Image); err == nil {
return nil
}
// Skip pulling if the image is referenced by digest and already
// exists locally.
named, err := reference.ParseNamed(spec.Image)