Skip to content

Add --platform flag support for platform-aware image pulls#180

Open
kcq wants to merge 1 commit intomasterfrom
fix-multiarch-pull-platform-docker-29-17122436149153391814
Open

Add --platform flag support for platform-aware image pulls#180
kcq wants to merge 1 commit intomasterfrom
fix-multiarch-pull-platform-docker-29-17122436149153391814

Conversation

@kcq
Copy link
Contributor

@kcq kcq commented Feb 28, 2026

This PR introduces a new --platform flag to several key commands (build, run, xray, profile, debug). This flag allows users to explicitly specify the target platform when pulling container images, addressing an issue in Docker 29 where the incorrect architecture variant of a multi-arch image might be selected when using the io.containerd.snapshotter.v1 storage driver.

The platform value is passed from the CLI all the way down to the container runtime client's pull options. Support has been explicitly added for the Docker and Containerd runtimes. For Podman, a TODO was added as the current bindings don't easily expose the platform parameter for pulls.

Fixes #174


PR created automatically by Jules for task 17122436149153391814 started by @kcq

…age pull issue

Docker 29 with the io.containerd.snapshotter.v1 storage driver sometimes fails to
automatically select the correct architecture variant when pulling multi-arch images.
This change adds an explicit --platform flag to the build (slim), run, xray, profile,
and debug commands, allowing users to specify the desired platform (e.g., linux/arm64).

Steps taken:
1. Added FlagPlatform to common CLI flags in pkg/app/master/command/cliflags.go.
2. Added Platform field to crt.PullImageOptions struct in pkg/crt/clients.go.
3. Updated PullImage implementation in pkg/crt/docker/dockercrtclient/dockercrtclient.go
   to pass the platform to the underlying Docker client.
4. Updated the image inspector's Pull method in pkg/app/master/inspectors/image/image_inspector.go
   to accept and use the platform parameter.
5. Updated build, run, xray, profile, and debug commands (CLI and handlers)
   to retrieve the --platform flag value and pass it through to the pull logic.
6. Verified that the project compiles with the new changes.

Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@kilo-code-bot
Copy link

kilo-code-bot bot commented Feb 28, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (19 files)
  • pkg/app/master/command/build/cli.go
  • pkg/app/master/command/build/handler.go
  • pkg/app/master/command/build/image.go
  • pkg/app/master/command/build/kubernetes.go
  • pkg/app/master/command/cliflags.go
  • pkg/app/master/command/debug/cli.go
  • pkg/app/master/command/debug/handle_containerd_runtime.go
  • pkg/app/master/command/debug/handle_docker_runtime.go
  • pkg/app/master/command/debug/handle_kubernetes_runtime.go
  • pkg/app/master/command/debug/handle_podman_runtime.go
  • pkg/app/master/command/profile/cli.go
  • pkg/app/master/command/profile/handler.go
  • pkg/app/master/command/run/cli.go
  • pkg/app/master/command/run/handler.go
  • pkg/app/master/command/xray/cli.go
  • pkg/app/master/command/xray/handler.go
  • pkg/app/master/inspectors/image/image_inspector.go
  • pkg/crt/clients.go
  • pkg/crt/docker/dockercrtclient/dockercrtclient.go

@dosubot
Copy link

dosubot bot commented Feb 28, 2026

Related Documentation

Checked 2 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@augmentcode
Copy link

augmentcode bot commented Feb 28, 2026

🤖 Augment PR Summary

Summary: Adds a new --platform flag to force platform-aware pulls for multi-arch images (mitigating Docker 29 wrong-arch selection with the containerd snapshotter).
Changes:

  • Introduced a common platform CLI flag (env DSLIM_PLATFORM) and exposed it on build, run, xray, profile, and debug.
  • Threaded the value through command handlers into image.Inspector.Pull / crt.PullImageOptions.
  • Docker pulls now pass Platform; containerd debug pulls add containerd.WithPlatform when set.
  • Podman support is noted as a TODO for platform-specific pulls.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

FlagRegistryAccount = "registry-account"
FlagRegistrySecret = "registry-secret"
FlagShowPullLogs = "show-plogs"
FlagPlatform = "platform"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR also adds a root-level mint file marked as a binary in the diff; can you confirm this isn’t an accidentally-committed build artifact (it can bloat the repo and makes review/auditing harder)?

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

logger.WithError(err).Trace("api.ImageService.Get")
logger.Debugf("api.Pull(%s)", commandParams.DebugContainerImage)
debugImage, err = api.Pull(ctx, commandParams.DebugContainerImage, containerd.WithPullUnpack)
pullOpts := []containerd.RemoteOpt{containerd.WithPullUnpack}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When --platform is set but the debug image already exists locally, this code skips api.Pull(...), so the local image may still reflect a different platform variant/unpack than requested.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

Multiarch build issue with docker 29

1 participant