diff --git a/.all-contributorsrc b/.all-contributorsrc index 51baed4d..a278c2b2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -121,6 +121,15 @@ "contributions": [ "doc" ] + }, + { + "login": "Shanduur", + "name": "Mateusz Urbanek", + "avatar_url": "https://avatars.githubusercontent.com/u/32583062?v=4", + "profile": "http://shanduur.github.io", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index 10975e91..81728058 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/rancher/k3d?style=flat-square)](https://goreportcard.com/report/github.com/rancher/k3d) -[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](code_of_conduct.md) @@ -139,6 +139,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Nuno do Carmo

🖋 ✅ 💬
Erwin Kersten

📖
Alex Sears

📖 +
Mateusz Urbanek

💻 diff --git a/pkg/runtimes/docker/container.go b/pkg/runtimes/docker/container.go index 0789f362..956af92f 100644 --- a/pkg/runtimes/docker/container.go +++ b/pkg/runtimes/docker/container.go @@ -192,22 +192,31 @@ func executeCheckInContainer(ctx context.Context, image string, cmd []string) (i } defer docker.Close() - if err = pullImage(ctx, docker, image); err != nil { - return -1, err - } - - resp, err := docker.ContainerCreate(ctx, &container.Config{ - Image: image, - Cmd: cmd, - Tty: false, - Entrypoint: []string{}, - }, nil, nil, nil, "") - if err != nil { - l.Log().Errorf("Failed to create container from image %s with cmd %s", image, cmd) - return -1, err + // create container + var resp container.ContainerCreateCreatedBody + for { + resp, err = docker.ContainerCreate(ctx, &container.Config{ + Image: image, + Cmd: cmd, + Tty: false, + Entrypoint: []string{}, + }, nil, nil, nil, "") + if err != nil { + if client.IsErrNotFound(err) { + if err := pullImage(ctx, docker, image); err != nil { + l.Log().Errorf("Failed to create container from image %s with cmd %s", image, cmd) + return -1, err + } + continue + } + l.Log().Errorf("Failed to create container from image %s with cmd %s", image, cmd) + return -1, err + } + break } if err = startContainer(ctx, resp.ID); err != nil { + l.Log().Errorf("Failed to start container from image %s with cmd %s", image, cmd) return -1, err }