diff --git a/daemon/cluster/cluster.go b/daemon/cluster/cluster.go index 8bb46a6998..b2afe15eef 100644 --- a/daemon/cluster/cluster.go +++ b/daemon/cluster/cluster.go @@ -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" @@ -1024,6 +1025,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 diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index 010c18c5b3..1613b1d114 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -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)