mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 01:06:27 +00:00
moby: check architecture for docker image
under certain cases the container image is already in the local docker registry, but with the wrong architecture; in this case just pretend it is not there and let the caller decide if they want to build it Signed-off-by: Christoph Ostarek <christoph@zededa.com>
This commit is contained in:
parent
5f09346e1e
commit
cb8f36adf3
@ -3,6 +3,7 @@ package docker
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
@ -51,13 +52,19 @@ func createClient() (*client.Client, error) {
|
||||
}
|
||||
|
||||
// HasImage check if the provided ref is available in the docker cache.
|
||||
func HasImage(ref *reference.Spec) error {
|
||||
func HasImage(ref *reference.Spec, architecture string) error {
|
||||
log.Debugf("docker inspect image: %s", ref)
|
||||
cli, err := Client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = InspectImage(cli, ref)
|
||||
imageInspect, err := InspectImage(cli, ref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if imageInspect.Architecture != "" && imageInspect.Architecture != architecture {
|
||||
return fmt.Errorf("image not found for right architecture (%s != %s)", imageInspect.Architecture, architecture)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func imagePull(ref *reference.Spec, alwaysPull bool, cacheDir string, dockerCach
|
||||
// - !alwaysPull && !dockerCache: try linuxkit cache, then try to pull from registry, then fail
|
||||
// first, try docker, if that is available
|
||||
if !alwaysPull && dockerCache {
|
||||
if err := docker.HasImage(ref); err == nil {
|
||||
if err := docker.HasImage(ref, architecture); err == nil {
|
||||
return docker.NewSource(ref), nil
|
||||
}
|
||||
// docker is not required, so any error - image not available, no docker, whatever - just gets ignored
|
||||
|
Loading…
Reference in New Issue
Block a user