fix(docker): respect skipDefaultTag in run target command#35421
Draft
FrozenPandaz wants to merge 1 commit into
Draft
fix(docker): respect skipDefaultTag in run target command#35421FrozenPandaz wants to merge 1 commit into
FrozenPandaz wants to merge 1 commit into
Conversation
When skipDefaultTag is true, the build target does not create the default
`${imageRef}` tag, so `docker run` should not append it to the command.
Without this fix, `docker run` fails (or Docker parses the trailing
imageRef as an in-container command) when skipDefaultTag is enabled.
Fixes #34230
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 7e68619
☁️ Nx Cloud last updated this comment at |
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.
Current Behavior
When
buildTarget.skipDefaultTagistruein the@nx/dockerplugin configuration, the plugin still hardcodes the default${imageRef}into the generateddocker:runtarget command:But when
skipDefaultTag: true, the build target intentionally does not create the${imageRef}tag (see the matching handling atplugin.ts:202-207). The run target then tries to run an image tag that was never built, sodocker runeither fails outright or — if the tag happens to match something in Docker's index — interprets the trailingimageRefas an in-container command, producing confusing output.Expected Behavior
When
skipDefaultTag: true, the generateddocker:runcommand should omit the${imageRef}suffix so users can pass the correct image reference through{args}(typically a custom tag they set via--tag custom:refon the build). WhenskipDefaultTagisfalseor unset, the existing behavior is preserved and${imageRef}is still appended.New behavior:
Symmetric unit tests are added under the existing
describe('skipDefaultTag', ...)block inplugin.spec.tscovering both thetrueandfalse/undefinedcases againsttargets['docker:run'].command.Related Issue(s)
Fixes #34230