Skip to content

Commit 1892be8

Browse files
committed
Don't use "info.IndexServerAddress" for authentication
The IndexServerAddress field was as part of the initial Windows implementation of the engine. For legal reasons, Microsoft Windows (and thus Docker images based on Windows) were not allowed to be distributed through non-Microsoft infrastructure. As a temporary solution, a dedicated "registry-win-tp3.docker.io" registry was created to serve Windows images. Using separate registries was not an ideal solution, and a more permanent solution was created by introducing "foreign image layers" in the distribution spec, after which the "registry-win-tp3.docker.io" ceased to exist, and removed from the engine. This replaces the code that calls out to the "/info" endpoint to use the GetAuthConfigKey() function instead. Related PR in docker/cli: docker/cli@b4ca1c7 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent a4af5e2 commit 1892be8

File tree

2 files changed

+8
-34
lines changed

2 files changed

+8
-34
lines changed

pkg/compose/compose.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,8 @@ func getContainerNameWithoutProject(c moby.Container) string {
123123

124124
func (s *composeService) Config(ctx context.Context, project *types.Project, options api.ConfigOptions) ([]byte, error) {
125125
if options.ResolveImageDigests {
126-
info, err := s.apiClient().Info(ctx)
127-
if err != nil {
128-
return nil, err
129-
}
130-
err = project.ResolveImages(func(named reference.Named) (digest.Digest, error) {
131-
auth, err := encodedAuth(named, info, s.configFile())
126+
err := project.ResolveImages(func(named reference.Named) (digest.Digest, error) {
127+
auth, err := encodedAuth(named, s.configFile())
132128
if err != nil {
133129
return "", err
134130
}

pkg/compose/pull.go

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ func (s *composeService) Pull(ctx context.Context, project *types.Project, optio
4848
}
4949

5050
func (s *composeService) pull(ctx context.Context, project *types.Project, opts api.PullOptions) error { //nolint:gocyclo
51-
info, err := s.apiClient().Info(ctx)
52-
if err != nil {
53-
return err
54-
}
55-
56-
if info.IndexServerAddress == "" {
57-
info.IndexServerAddress = registry.IndexServer
58-
}
59-
6051
images, err := s.getLocalImagesDigests(ctx, project)
6152
if err != nil {
6253
return err
@@ -123,7 +114,7 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
123114
imagesBeingPulled[service.Image] = service.Name
124115

125116
eg.Go(func() error {
126-
_, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false, project.Environment["DOCKER_DEFAULT_PLATFORM"])
117+
_, err := s.pullServiceImage(ctx, service, s.configFile(), w, false, project.Environment["DOCKER_DEFAULT_PLATFORM"])
127118
if err != nil {
128119
pullErrors[i] = err
129120
if service.Build != nil {
@@ -173,7 +164,7 @@ func imageAlreadyPresent(serviceImage string, localImages map[string]string) boo
173164
return ok && tagged.Tag() != "latest"
174165
}
175166

176-
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig, info moby.Info,
167+
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig,
177168
configFile driver.Auth, w progress.Writer, quietPull bool, defaultPlatform string) (string, error) {
178169
w.Event(progress.Event{
179170
ID: service.Name,
@@ -185,7 +176,7 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
185176
return "", err
186177
}
187178

188-
encodedAuth, err := encodedAuth(ref, info, configFile)
179+
encodedAuth, err := encodedAuth(ref, configFile)
189180
if err != nil {
190181
return "", err
191182
}
@@ -249,17 +240,13 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
249240
return inspected.ID, nil
250241
}
251242

252-
func encodedAuth(ref reference.Named, info moby.Info, configFile driver.Auth) (string, error) {
243+
func encodedAuth(ref reference.Named, configFile driver.Auth) (string, error) {
253244
repoInfo, err := registry.ParseRepositoryInfo(ref)
254245
if err != nil {
255246
return "", err
256247
}
257248

258-
key := repoInfo.Index.Name
259-
if repoInfo.Index.Official {
260-
key = info.IndexServerAddress
261-
}
262-
249+
key := registry.GetAuthConfigKey(repoInfo.Index)
263250
authConfig, err := configFile.GetAuthConfig(key)
264251
if err != nil {
265252
return "", err
@@ -273,15 +260,6 @@ func encodedAuth(ref reference.Named, info moby.Info, configFile driver.Auth) (s
273260
}
274261

275262
func (s *composeService) pullRequiredImages(ctx context.Context, project *types.Project, images map[string]string, quietPull bool) error {
276-
info, err := s.apiClient().Info(ctx)
277-
if err != nil {
278-
return err
279-
}
280-
281-
if info.IndexServerAddress == "" {
282-
info.IndexServerAddress = registry.IndexServer
283-
}
284-
285263
var needPull []types.ServiceConfig
286264
for _, service := range project.Services {
287265
if service.Image == "" {
@@ -311,7 +289,7 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
311289
for i, service := range needPull {
312290
i, service := i, service
313291
eg.Go(func() error {
314-
id, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
292+
id, err := s.pullServiceImage(ctx, service, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
315293
pulledImages[i] = id
316294
if err != nil && isServiceImageToBuild(service, project.Services) {
317295
// image can be built, so we can ignore pull failure

0 commit comments

Comments
 (0)