Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

fix: prevent incorrect Docker Hub links for private registries#200

Closed
saishparadkar10 wants to merge 2 commits into
microsoft:mainfrom
saishparadkar10:fix/private-registry-hover-link
Closed

fix: prevent incorrect Docker Hub links for private registries#200
saishparadkar10 wants to merge 2 commits into
microsoft:mainfrom
saishparadkar10:fix/private-registry-hover-link

Conversation

@saishparadkar10

@saishparadkar10 saishparadkar10 commented Jul 8, 2026

Copy link
Copy Markdown

Summary

This PR fixes a bug where hovering over an image: field containing a private/custom registry reference incorrectly generates a DocumentLink pointing to Docker Hub.

This PR addresses the issue in two ways:

  1. Keeps Compose image links local: We set imageLinks: false in AlternateYamlLanguageServiceClientFeature.ts (similar to Keep Compose image links local when Docker is present #198) so that the Compose language service maintains control over image links even when the Docker extension is present, rather than delegating it to Docker's buggy provider.
  2. Corrects registry hostname parsing in ImageLinkProvider: We refactored getLinkForImage in ImageLinkProvider.ts to verify whether the first segment of the image path is a registry hostname (by checking for ., :, or if it is equal to localhost). If a custom/private registry is detected, no link is generated (except for the special mcr.microsoft.com case). This prevents the Compose provider itself from incorrectly linking local or custom registries (e.g. localhost/alpine or custom hostnames) to Docker Hub.

Fixes #179.

Root cause

  1. By default, when the Docker extension was present, the Compose language service stopped providing image links and delegated them to Docker's extension, which turned private registry refs into Docker Hub URLs.
  2. Even when the Compose language service's own provider was used, its regular expressions did not check if the namespace/registry part contained dots, ports, or represented a local registry (localhost), leading it to match private registry names as Docker Hub namespaces.

Solution

  • Set imageLinks: false in AlternateYamlLanguageServiceClientFeature.ts to disable delegation when Docker is present.
  • Updated getLinkForImage in ImageLinkProvider.ts to detect registry hostnames in image paths.
  • Added unit tests in ImageLinkProvider.test.ts to cover localhost/alpine and private registry images (e.g., nrt.vultrcr.com/wulicoco/code-sync).

Testing performed

  • Verified all 119 unit tests pass locally (npm test).
  • Verified build and lint checks pass.

Limitations

None.

@saishparadkar10
saishparadkar10 requested a review from a team as a code owner July 8, 2026 18:05
@saishparadkar10

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@bwateratmsft

Copy link
Copy Markdown
Collaborator

This looks similar to #198; can you check if it's the Docker DX extension that's contributing these links?

@saishparadkar10

Copy link
Copy Markdown
Author

Yes, you are correct. When the Docker extension is present, it overrides Compose's image links due to imageLinks: docker in AlternateYamlLanguageServiceClientFeature.ts (as described in #198).

I have updated this PR to include the fix from #198 (setting imageLinks: false so Compose retains local control) alongside our parsing fix in ImageLinkProvider.ts.

This ensures private/custom registry names (including single-word hostnames like localhost) are not incorrectly linked to Docker Hub by either provider.

@bwateratmsft

Copy link
Copy Markdown
Collaborator

Going to merge #191 instead, but including the change this PR has to keep image linking even when Docker DX is present.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hover link on image: field in compose.yaml always points to Docker Hub, even for private registries

2 participants