Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented May 26, 2025

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

`docker image rm`: add `--platform` option to remove a variant from multi-platform images.

- A picture of a cute animal (not mandatory but encouraged)

flags.BoolVarP(&opts.force, "force", "f", false, "Force removal of the image")
flags.BoolVar(&opts.noPrune, "no-prune", false, "Do not delete untagged parents")

// TODO(thaJeztah): create a "platforms" option for this (including validation / parsing).
Copy link
Member Author

Choose a reason for hiding this comment

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

Working on this as well, but we can merge those changes later.

@codecov-commenter
Copy link

codecov-commenter commented May 26, 2025

Codecov Report

Attention: Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 55.03%. Comparing base (f567263) to head (bb0ca9f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6109      +/-   ##
==========================================
- Coverage   55.04%   55.03%   -0.01%     
==========================================
  Files         361      361              
  Lines       30142    30152      +10     
==========================================
+ Hits        16591    16595       +4     
- Misses      12594    12599       +5     
- Partials      957      958       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@thaJeztah thaJeztah force-pushed the image_rm_platform branch 2 times, most recently from 91cf9c6 to 350e90f Compare May 27, 2025 08:53
@thaJeztah thaJeztah marked this pull request as ready for review May 27, 2025 08:53
@thaJeztah thaJeztah requested a review from a team as a code owner May 27, 2025 08:53
func NewRemoveCommand(dockerCli command.Cli) *cobra.Command {
var opts removeOptions
func NewRemoveCommand(dockerCLI command.Cli) *cobra.Command {
var options removeOptions
Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW; renamed this one in preparation of adding an options to the opts package (preventing this var from shadowing the import).

@thaJeztah thaJeztah force-pushed the image_rm_platform branch 2 times, most recently from 479f1d7 to e7bba37 Compare May 27, 2025 08:57
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copy link
Collaborator

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@thaJeztah
Copy link
Member Author

FWIW (still need to write up) there may be some corner-cases to still look into for that feature; trying to remove a platform that doesn’t exist in the cache still errors, even with --force, where it should probably get a 404 / not-found and (due to --force) ignore it;

docker image ls --tree alpine

IMAGE                   ID             DISK USAGE   CONTENT SIZE   EXTRA
alpine:latest           a8560b36e8b8       37.8MB         11.2MB
├─ linux/amd64          1c4eef651f65       12.1MB         3.64MB
├─ linux/arm/v6         903bfe2ae994           0B             0B
├─ linux/arm/v7         9c2d245b3c01           0B             0B
├─ linux/arm64/v8       757d680068d7       12.8MB         3.99MB
├─ linux/386            2436f2b3b7d2           0B             0B
├─ linux/ppc64le        9ed53fd3b831       12.8MB         3.58MB
├─ linux/riscv64        1de5eb4a9a67           0B             0B
└─ linux/s390x          fe0dcdd1f783           0B             0B


$ docker-linux-arm64 image rm --platform=linux/s390x --force alpine
Error response from daemon: failed to delete platform linux/s390x for image sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c: image with reference alpine:latest was found but does not provide any platform
@thaJeztah
Copy link
Member Author

I'll bring this one in; the above should not be a blocker for this (we can fix / improve).

@thaJeztah thaJeztah merged commit 17dc288 into docker:master May 27, 2025
102 of 103 checks passed
@thaJeztah thaJeztah deleted the image_rm_platform branch May 27, 2025 10:11
@thaJeztah
Copy link
Member Author

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

3 participants