mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
docker-container: check local image store if pulling image failed
When booting `docker-container` driver, it will pull and run image `moby/buildkit:buildx-stable-1`. If current node cannot connect to dockerhub, driver `docker-container` will always booting failure. But user may already load the image manually or pull it from a priviate registry. Buildx should check local docker image store after pull failed. Fixes: #199 issuecomment-561996661 Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com>
This commit is contained in:
parent
8bce430f4d
commit
5b9d88b3ad
@ -57,7 +57,7 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
||||
if d.image != "" {
|
||||
imageName = d.image
|
||||
}
|
||||
env := d.env
|
||||
|
||||
if err := l.Wrap("pulling image "+imageName, func() error {
|
||||
rc, err := d.DockerAPI.ImageCreate(ctx, imageName, types.ImageCreateOptions{})
|
||||
if err != nil {
|
||||
@ -66,12 +66,18 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
||||
_, err = io.Copy(ioutil.Discard, rc)
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
// image pulling failed, check if it exists in local image store.
|
||||
// if not, return pulling error. otherwise log it.
|
||||
_, _, errInspect := d.DockerAPI.ImageInspectWithRaw(ctx, imageName)
|
||||
if errInspect != nil {
|
||||
return err
|
||||
}
|
||||
l.Wrap("pulling failed, using local image "+imageName, func() error { return nil })
|
||||
}
|
||||
|
||||
cfg := &container.Config{
|
||||
Image: imageName,
|
||||
Env: env,
|
||||
Env: d.env,
|
||||
}
|
||||
if d.InitConfig.BuildkitFlags != nil {
|
||||
cfg.Cmd = d.InitConfig.BuildkitFlags
|
||||
|
Loading…
x
Reference in New Issue
Block a user