Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Removing Exit Code #2400

Open
oguzhanoyan opened this issue Jul 29, 2023 · 2 comments
Open

Image Removing Exit Code #2400

oguzhanoyan opened this issue Jul 29, 2023 · 2 comments
Labels
question Further information is requested

Comments

@oguzhanoyan
Copy link

Description

Hello when I am trying to remove image with --force flag, even though not existing image, bash is showing that, command execution is successfully which means 0. Here are three different situation;

command output exit-code comment
nerdctl image rm -f image_name --namespace k8s.io ERRO[0000] 1 errors: no such image: image_name 0 There is no container named container_name and didnt remove, but exit code is 0 which means succesfully, I am expecting exit code 1
nerdctl image rm image_name --namespace k8s.io ERRO[0000] 1 errors: no such image: image_name 1 Normal behavior there is no problem
nerdctl image rm -f existing_image --namespace k8s.io - 0 Normal behavior there is no problem

image

Steps to reproduce the issue

  1. nerdctl image rm -f image_name --namespace k8s.io

Describe the results you received and expected

I am expecting exit code 1 even though i forced to remove to not existing image.

What version of nerdctl are you using?

nerdctl version 1.4.0

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

No response

@oguzhanoyan oguzhanoyan added the kind/unconfirmed-bug-claim Unconfirmed bug claim label Jul 29, 2023
@fahedouch fahedouch added bug Something isn't working and removed kind/unconfirmed-bug-claim Unconfirmed bug claim labels Jul 29, 2023
@suyanhanx
Copy link
Contributor

Thank you for taking the time to report the behavior you observed with the nerdctl rmi -f command when attempting to remove a non-existent image.

After conducting a thorough investigation and referencing Docker's behavior, I can confirm that this is not a bug, but the intended behavior. When Docker encounters a non-existent image, the docker rmi -f command is designed to return an exit code of 0 to silently fail the operation. This approach is chosen so as to not disrupt scripts or automated processes that might be using this command. The command still prints out an error message to inform the user of the attempt to remove a non-existent image.
Therefore, as nerdctl is a Docker-compatible command line, it is expected for nerdctl rmi -f to replicate this behavior. When attempting to remove a non-existent image, it should return an exit code of 0 while still printing an error message.

FYI:

@AkihiroSuda AkihiroSuda added question Further information is requested and removed bug Something isn't working labels Jul 30, 2023
@fahedouch
Copy link
Member

IMO we need to provide better error message formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants