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

Fix error when trying to delete an image due to a bad container #13527

Merged
merged 1 commit into from
May 29, 2015

Conversation

duglin
Copy link
Contributor

@duglin duglin commented May 28, 2015

I ran into a situation where I was trying:
docker rmi busybox
and it kept failing saying:
could not find image: Prefix can't be empty

While I have no idea how I got into this situation, it turns out this is
error message is from daemon.canDeleteImage(). In that func we loop over
all containers checking to see if they're using the image we're trying to
delete. In my case though, I had a container with no ImageID. So the code
would die trying to find that image (hence the "Prefix can't be empty" err).
This would stop all processing despite the fact that the container we're
checking had nothing to do with 'busybox'.

My change logs the bad situation in the logs and then skips that container.
There's no reason to fail all docker rmi ... calls just because of one
bad container.

Will continue to try to figure out how I got a container w/o an ImageID
but as of now I have no idea, I didn't do anything but normal docker cli
commands.

Signed-off-by: Doug Davis dug@us.ibm.com

// on would fail with a "Prefix can't be empty" error even
// though the bad container has nothing to do with the image
// we're trying to delete.
logrus.Errorf("Container %q has no image associted with it!", container.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

associated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed- thanks!

I ran into a situation where I was trying:
	`docker rmi busybox`
and it kept failing saying:
    `could not find image: Prefix can't be empty`

While I have no idea how I got into this situation, it turns out this is
error message is from `daemon.canDeleteImage()`. In that func we loop over
all containers checking to see if they're using the image we're trying to
delete.  In my case though, I had a container with no ImageID. So the code
would die tryig to find that image (hence the "Prefix can't be empty" err).
This would stop all processing despite the fact that the container we're
checking had nothing to do with 'busybox'.

My change logs the bad situation in the logs and then skips that container.
There's no reason to fail all `docker rmi ...` calls just because of one
bad container.

Will continue to try to figure out how I got a container w/o an ImageID
but as of now I have no idea, I didn't do anything but normal docker cli
commands.

Signed-off-by: Doug Davis <dug@us.ibm.com>
@duglin duglin force-pushed the FixImagesPrefixNotFound branch from 996631e to 71a4990 Compare May 28, 2015 02:20
@duglin
Copy link
Contributor Author

duglin commented May 28, 2015

In case people are wondering why this situation isn't a problem in other areas of the code, it actually is. While debugging I found several other flows where this error is generated, but in each case the error was eventually ignored and processing continued. So, in that respect this fix is consistent with those other cases I came across.

@calavera
Copy link
Contributor

LGTM

@duglin
Copy link
Contributor Author

duglin commented May 29, 2015

ping @jfrazelle @LK4D4

@jessfraz
Copy link
Contributor

is this for 1.7

@duglin
Copy link
Contributor Author

duglin commented May 29, 2015

@jfrazelle I haven't heard of other people complaining about seeing this error so I don't think its critical for 1.7, despite it being very safe.

@jessfraz
Copy link
Contributor

LGTM

jessfraz pushed a commit that referenced this pull request May 29, 2015
Fix error when trying to delete an image due to a bad container
@jessfraz jessfraz merged commit a39de41 into moby:master May 29, 2015
@duglin duglin deleted the FixImagesPrefixNotFound branch July 10, 2015 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants