Skip to content

fix(docker): respect skipDefaultTag in run target command#35421

Draft
FrozenPandaz wants to merge 1 commit into
masterfrom
fix/34230-docker-skip-default-tag
Draft

fix(docker): respect skipDefaultTag in run target command#35421
FrozenPandaz wants to merge 1 commit into
masterfrom
fix/34230-docker-skip-default-tag

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

Current Behavior

When buildTarget.skipDefaultTag is true in the @nx/docker plugin configuration, the plugin still hardcodes the default ${imageRef} into the generated docker:run target command:

// packages/docker/src/plugins/plugin.ts (before this PR)
command: `docker run {args} ${imageRef}`,

But when skipDefaultTag: true, the build target intentionally does not create the ${imageRef} tag (see the matching handling at plugin.ts:202-207). The run target then tries to run an image tag that was never built, so docker run either fails outright or — if the tag happens to match something in Docker's index — interprets the trailing imageRef as an in-container command, producing confusing output.

Expected Behavior

When skipDefaultTag: true, the generated docker:run command should omit the ${imageRef} suffix so users can pass the correct image reference through {args} (typically a custom tag they set via --tag custom:ref on the build). When skipDefaultTag is false or unset, the existing behavior is preserved and ${imageRef} is still appended.

New behavior:

command: interpolatedBuildTarget.skipDefaultTag
  ? `docker run {args}`
  : `docker run {args} ${imageRef}`,

Symmetric unit tests are added under the existing describe('skipDefaultTag', ...) block in plugin.spec.ts covering both the true and false/undefined cases against targets['docker:run'].command.

Related Issue(s)

Fixes #34230

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
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 7e68619
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69eb0fbd8454ed0008a89305
😎 Deploy Preview https://deploy-preview-35421--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 7e68619
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69eb0fbd92299c00082184b0
😎 Deploy Preview https://deploy-preview-35421--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Apr 24, 2026

View your CI Pipeline Execution ↗ for commit 7e68619

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 55m 47s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 4s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 16s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 23s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-24 07:37:43 UTC

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@nx/docker:docker:run does not respect skipDefaultTag

1 participant