提交 5d162811 编写于 作者: P Priya Wadhwa

use docker command line to check if image exists, since it is much faster than go-containerregistry

上级 3d291fd6
......@@ -20,6 +20,7 @@ import (
"context"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
......@@ -86,14 +87,18 @@ func WriteImageToDaemon(img string) error {
return errors.Wrap(err, "point host docker-daemon")
}
// Check if image exists locally
cmd := exec.Command("docker", "images", "--format", "{{.Repository}}:{{.Tag}}@{{.Digest}}")
if output, err := cmd.Output(); err == nil {
if strings.Contains(string(output), img) {
glog.Infof("Found %s in local docker daemon, skipping pull", img)
return nil
}
}
// Else, pull it
ref, err := name.ParseReference(img)
if err != nil {
return errors.Wrap(err, "parsing reference")
}
if _, err := daemon.Image(ref); err == nil {
glog.Infof("Found %s in local docker daemon, skipping pull", img)
return nil
}
i, err := remote.Image(ref)
if err != nil {
return errors.Wrap(err, "getting remote image")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册