mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
7a9cb29fb9
This enables image lookup when creating a container to fail when the reference exists but it is for the wrong platform. This prevents trying to run an image for the wrong platform, as can be the case with, for example binfmt_misc+qemu. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
27 lines
650 B
Go
27 lines
650 B
Go
package images // import "github.com/docker/docker/daemon/images"
|
|
|
|
import (
|
|
"github.com/docker/docker/builder"
|
|
"github.com/docker/docker/image/cache"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// MakeImageCache creates a stateful image cache.
|
|
func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
|
if len(sourceRefs) == 0 {
|
|
return cache.NewLocal(i.imageStore)
|
|
}
|
|
|
|
cache := cache.New(i.imageStore)
|
|
|
|
for _, ref := range sourceRefs {
|
|
img, err := i.GetImage(ref, nil)
|
|
if err != nil {
|
|
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
|
|
continue
|
|
}
|
|
cache.Populate(img)
|
|
}
|
|
|
|
return cache
|
|
}
|