Merge pull request #13527 from duglin/FixImagesPrefixNotFound

Fix error when trying to delete an image due to a bad container
This commit is contained in:
Jessie Frazelle 2015-05-29 14:09:26 -07:00
commit a39de41871
1 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/graph"
"github.com/docker/docker/image"
@ -140,6 +141,16 @@ func (daemon *Daemon) imgDeleteHelper(name string, list *[]types.ImageDelete, fi
func (daemon *Daemon) canDeleteImage(imgID string, force bool) error {
for _, container := range daemon.List() {
if container.ImageID == "" {
// This technically should never happen, but if the container
// has no ImageID then log the situation and move on.
// If we allowed processing to continue then the code later
// 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 associated with it!", container.ID)
continue
}
parent, err := daemon.Repositories().LookupImage(container.ImageID)
if err != nil {
if daemon.Graph().IsNotExist(err, container.ImageID) {