Avoid downloading image if present locally

This commit is contained in:
Mahmood Ali 2018-11-12 21:39:23 -05:00
parent ac3b4571eb
commit 470d20cdf3

View file

@ -21,20 +21,23 @@ func TestDockerLogger(t *testing.T) {
t.Skip("docker unavailable:", err)
}
if img, err := client.InspectImage("busybox:1"); err != nil || img == nil {
t.Log("image not found locally, downloading...")
err = client.PullImage(docker.PullImageOptions{
Repository: "alpine",
Tag: "latest",
Repository: "busybox",
Tag: "1",
}, docker.AuthConfiguration{})
if err != nil {
t.Fatalf("failed to pull image: %v", err)
}
}
containerConf := docker.CreateContainerOptions{
Config: &docker.Config{
Cmd: []string{
"/bin/ash", "-c", "touch /tmp/docklog; tail -f /tmp/docklog",
"/bin/sh", "-c", "touch /tmp/docklog; tail -f /tmp/docklog",
},
Image: "alpine:latest",
Image: "busybox:1",
},
Context: context.Background(),
}