Skip to content

Commit

Permalink
run --rmi: "cannot remove" is a warning, not an error
Browse files Browse the repository at this point in the history
When the "rmi" part of "run --rmi" fails due to image being in use
by another container (or for any reason, actually), issue a warning
message, not an error.

Signed-off-by: Ed Santiago <[email protected]>
  • Loading branch information
edsantiago committed Sep 7, 2023
1 parent e546aeb commit 0f45e3c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/podman/containers/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func run(cmd *cobra.Command, args []string) error {
if runRmi {
_, rmErrors := registry.ImageEngine().Remove(registry.GetContext(), []string{imageName}, entities.ImageRemoveOptions{})
if len(rmErrors) > 0 {
logrus.Errorf("%s", errorhandling.JoinErrors(rmErrors))
logrus.Warn(errorhandling.JoinErrors(rmErrors))
}
}
if cmd.Flag("gpus").Changed {
Expand Down
2 changes: 1 addition & 1 deletion test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ echo $rand | 0 | $rand
run_podman image exists $NONLOCAL_IMAGE

# Now try running with --rmi : it should succeed, but not remove the image
run_podman 0+e run --rmi --rm $NONLOCAL_IMAGE /bin/true
run_podman 0+w run --rmi --rm $NONLOCAL_IMAGE /bin/true
is "$output" ".*image is in use by a container" "--rmi should warn that the image was not removed"
run_podman image exists $NONLOCAL_IMAGE

Expand Down
2 changes: 1 addition & 1 deletion test/upgrade/test-upgrade.bats
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ failed | exited | 17


@test "stop and rm" {
run_podman stop myrunningcontainer
run_podman 0+w stop myrunningcontainer
run_podman rm myrunningcontainer
}

Expand Down

0 comments on commit 0f45e3c

Please sign in to comment.