diff --git a/daemon/containerd/image_pull.go b/daemon/containerd/image_pull.go index 3e2f623319..8d2c873143 100644 --- a/daemon/containerd/image_pull.go +++ b/daemon/containerd/image_pull.go @@ -45,7 +45,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, } } - resolver, _ := i.newResolverFromAuthConfig(authConfig) + resolver, _ := i.newResolverFromAuthConfig(ctx, authConfig) opts = append(opts, containerd.WithResolver(resolver)) jobs := newJobs() diff --git a/daemon/containerd/image_push.go b/daemon/containerd/image_push.go index ae3814761d..f0a38ef63b 100644 --- a/daemon/containerd/image_push.go +++ b/daemon/containerd/image_push.go @@ -62,7 +62,7 @@ func (i *ImageService) PushImage(ctx context.Context, targetRef reference.Named, target := img.Target store := i.client.ContentStore() - resolver, tracker := i.newResolverFromAuthConfig(authConfig) + resolver, tracker := i.newResolverFromAuthConfig(ctx, authConfig) progress := pushProgress{Tracker: tracker} jobsQueue := newJobs() finishProgress := jobsQueue.showProgress(ctx, out, combinedProgress([]progressUpdater{ diff --git a/daemon/containerd/resolver.go b/daemon/containerd/resolver.go index 5edd83181b..97bc9780df 100644 --- a/daemon/containerd/resolver.go +++ b/daemon/containerd/resolver.go @@ -1,6 +1,7 @@ package containerd import ( + "context" "crypto/tls" "errors" "net/http" @@ -8,19 +9,23 @@ import ( "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" registrytypes "github.com/docker/docker/api/types/registry" + "github.com/docker/docker/dockerversion" "github.com/docker/docker/registry" "github.com/sirupsen/logrus" ) -func (i *ImageService) newResolverFromAuthConfig(authConfig *registrytypes.AuthConfig) (remotes.Resolver, docker.StatusTracker) { +func (i *ImageService) newResolverFromAuthConfig(ctx context.Context, authConfig *registrytypes.AuthConfig) (remotes.Resolver, docker.StatusTracker) { tracker := docker.NewInMemoryTracker() hostsFn := i.registryHosts.RegistryHosts() hosts := hostsWrapper(hostsFn, authConfig, i.registryService) + headers := http.Header{} + headers.Set("User-Agent", dockerversion.DockerUserAgent(ctx)) return docker.NewResolver(docker.ResolverOptions{ Hosts: hosts, Tracker: tracker, + Headers: headers, }), tracker }