diff --git a/libbeat/tests/docker/docker.go b/libbeat/tests/docker/docker.go index ce137da641c..afa18317eb9 100644 --- a/libbeat/tests/docker/docker.go +++ b/libbeat/tests/docker/docker.go @@ -20,6 +20,8 @@ package docker import ( "context" + "github.com/pkg/errors" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" @@ -41,9 +43,11 @@ func NewClient() (Client, error) { // ContainerStart pulls and starts the given container func (c Client) ContainerStart(image string, cmd []string, labels map[string]string) (string, error) { ctx := context.Background() - if _, err := c.cli.ImagePull(ctx, image, types.ImagePullOptions{}); err != nil { - return "", err + respBody, err := c.cli.ImagePull(ctx, image, types.ImagePullOptions{}) + if err != nil { + return "", errors.Wrapf(err, "pullling image %s", image) } + defer respBody.Close() resp, err := c.cli.ContainerCreate(ctx, &container.Config{ Image: image, @@ -51,11 +55,11 @@ func (c Client) ContainerStart(image string, cmd []string, labels map[string]str Labels: labels, }, nil, nil, "") if err != nil { - return "", err + return "", errors.Wrap(err, "creating container") } if err := c.cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil { - return "", err + return "", errors.Wrap(err, "starting container") } return resp.ID, nil