mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 01:06:27 +00:00
Merge pull request #4072 from christoph-zededa/docker_cache_consider_architecture
moby: check architecture for docker image
This commit is contained in:
commit
fa3207c86e
@ -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