diff --git a/docker_client.go b/docker_client.go index 49d1abf9ac..bfe06be7bc 100644 --- a/docker_client.go +++ b/docker_client.go @@ -40,8 +40,6 @@ func (c *DockerClient) Info(ctx context.Context) (types.Info, error) { dockerInfoOnce.Do(func() { dockerInfo, err = c.Client.Info(ctx) if err != nil { - // reset the state of the sync.Once so that the next call to Info will try again - dockerInfoOnce = sync.Once{} return } @@ -66,6 +64,11 @@ func (c *DockerClient) Info(ctx context.Context) (types.Info, error) { ) }) + if err != nil { + // reset the state of the sync.Once so that the next call to Info will try again + dockerInfoOnce = sync.Once{} + } + return dockerInfo, err }