Conversation
…ocker Hub
The Docker source type exposes `dockerImage` and `registryUrl` as separate
fields, and `buildRemoteDocker` passes the image to `docker pull` verbatim —
`registryUrl` only ever reaches `docker login`. A reference with no registry
host is therefore resolved to Docker Hub however the Registry URL is
configured, which surfaces as a confusing pair of lines:
Pulling amelio-dev:latest
Login Succeeded
Error response from daemon: pull access denied for amelio-dev, repository
does not exist or may require 'docker login'
The login targets the right registry and the pull goes to Hub. Nothing in the
log says so, and the `node:16` placeholder actively suggests the short form.
Detect the mismatch before the shell script runs and fail with the correction,
naming both the reference Docker actually resolves and the value to use. The
image is deliberately never rewritten: prefixing it automatically would break
the legitimate "authenticate to a private registry, pull a public Hub image"
setup.
Also reduce the auth address to a bare host. `AuthConfig.serveraddress` is
matched against the registry host of the image on the Swarm node, so a pasted
`https://registry.example.com/team/` could fail the node-side pull even once
the build-server pull succeeded. Docker Hub is passed through untouched — its
canonical auth key is the legacy `https://index.docker.io/v1/`, and rewriting
that to a hostname would store the credential under a key the pull never
looks up.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ocker Hub
The Docker source type exposes `dockerImage` and `registryUrl` as separate
fields, and `buildRemoteDocker` passes the image to `docker pull` verbatim —
`registryUrl` only ever reaches `docker login`. A reference with no registry
host is therefore resolved to Docker Hub however the Registry URL is
configured, which surfaces as a confusing pair of lines:
Pulling amelio-dev:latest
Login Succeeded
Error response from daemon: pull access denied for amelio-dev, repository
does not exist or may require 'docker login'
The login targets the right registry and the pull goes to Hub. Nothing in the
log says so, and the `node:16` placeholder actively suggests the short form.
Detect the mismatch before the shell script runs and fail with the correction,
naming both the reference Docker actually resolves and the value to use. The
image is deliberately never rewritten: prefixing it automatically would break
the legitimate "authenticate to a private registry, pull a public Hub image"
setup.
Also reduce the auth address to a bare host. `AuthConfig.serveraddress` is
matched against the registry host of the image on the Swarm node, so a pasted
`https://registry.example.com/team/` could fail the node-side pull even once
the build-server pull succeeded. Docker Hub is passed through untouched — its
canonical auth key is the legacy `https://index.docker.io/v1/`, and rewriting
that to a hostname would store the credential under a key the pull never
looks up.
…ocker Hub
The Docker source type exposes `dockerImage` and `registryUrl` as separate
fields, and `buildRemoteDocker` passes the image to `docker pull` verbatim —
`registryUrl` only ever reaches `docker login`. A reference with no registry
host is therefore resolved to Docker Hub however the Registry URL is
configured, which surfaces as a confusing pair of lines:
Pulling amelio-dev:latest
Login Succeeded
Error response from daemon: pull access denied for amelio-dev, repository
does not exist or may require 'docker login'
The login targets the right registry and the pull goes to Hub. Nothing in the
log says so, and the `node:16` placeholder actively suggests the short form.
Detect the mismatch before the shell script runs and fail with the correction,
naming both the reference Docker actually resolves and the value to use. The
image is deliberately never rewritten: prefixing it automatically would break
the legitimate "authenticate to a private registry, pull a public Hub image"
setup.
Also reduce the auth address to a bare host. `AuthConfig.serveraddress` is
matched against the registry host of the image on the Swarm node, so a pasted
`https://registry.example.com/team/` could fail the node-side pull even once
the build-server pull succeeded. Docker Hub is passed through untouched — its
canonical auth key is the legacy `https://index.docker.io/v1/`, and rewriting
that to a hostname would store the credential under a key the pull never
looks up.
Comment on lines
+21
to
+24
| const mismatch = findRegistryMismatch(dockerImage, registryUrl); | ||
| if (mismatch) { | ||
| throw new Error(mismatch); | ||
| } |
Contributor
There was a problem hiding this comment.
When an application uses a public Docker Hub image such as nginx:latest while retaining a non-Hub Registry URL and credentials, this check aborts the deployment before either login or pull runs. These settings are independent, and the previous flow could log in to the private registry before pulling the public Hub image, so applications with intentional or stale private-registry settings can no longer deploy a valid Hub image.
Knowledge Base Used: Build and Compose workflows
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
A Docker-source application whose Docker Image carries no registry host is pulled from
Docker Hub regardless of the configured Registry URL —
buildRemoteDockerpasses theimage to
docker pullverbatim andregistryUrlonly ever reachesdocker login. Thedeployment log shows
Login Succeededimmediately followed bypull access denied, withnothing saying the two commands addressed different registries.
This PR detects the mismatch before the shell script runs and fails with the correction:
The image is deliberately never rewritten. Prefixing it automatically would break the
legitimate "authenticate to a private registry, pull a public Hub image" setup, so the
mismatch is reported and the correction left to the user. Happy to switch to composition
if you'd rather — it's a one-line change in
findRegistryMismatch.Also included:
AuthConfig.serveraddressis reduced to a bare host. Swarm matches it against theregistry host of the image on the target node, so a pasted
https://registry.example.com/team/could fail the node-side pull even once thebuild-server pull succeeded — and that's a different machine, since the service is created
against
application.serverId. Docker Hub is passed through untouched: its canonical authkey is the legacy
https://index.docker.io/v1/, and normalising that to a hostname wouldstore the credential under a key the Hub pull never looks up.
FormDescriptionon each field states which command it feeds, and theDocker Image one spells out that a private-registry image must carry its host. The
placeholder stays a Docker Hub example (
nginx:latestrather than the oldnode:16):the short form is correct for Hub, so putting a registry host in the placeholder would
mislead the majority of users in the opposite direction. The rule belongs in the
description, which can state the condition the placeholder cannot.
New pure module
packages/server/src/utils/docker/registry-reference.ts;getImageRegistryHostmirrors
splitDockerDomainin distribution/reference (first component is a host when itcontains
.or:, islocalhost, or has an uppercase character).Checklist
canarybranch.Issues related (if applicable)
closes #5469
Notes for reviewers
No behaviour change for a working configuration: a fully-qualified image returns
nullfromfindRegistryMismatch, andregistryAuthAddressis a no-op on a value that is already abare host. The new refusal fires only on the pair that cannot work today.
findRegistryMismatchthrows frombuildRemoteDocker, sodeployApplication's non-ExecErrorbranch base64-encodes it into the deployment log — the message lands where the user is already
looking.
The PR is not safe to merge until it stops treating a public Docker Hub image combined with independent private-registry settings as a fatal mismatch.
Summary
This PR adds registry-reference parsing, rejects Docker-source image/registry mismatches before command execution, normalizes Swarm authentication addresses, updates form guidance, and adds unit tests.
Reviews (1) · Last reviewed commit: "fix(docker): report when a Docker-source..."