Skip to content

Commit

Permalink
fix: check if the discovered docker socket responds
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Aug 21, 2024
1 parent 6ab1134 commit 19fb55b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/core/docker_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ func extractDockerHost(ctx context.Context) string {
continue
}

// check if the docker host responds to an Info request
// we are going to use the default Docker client to check if the host is reachable
// which will avoid recursive calls to this function
cli, err := client.NewClientWithOpts(client.WithHost(dockerHost))
if err != nil {
outerErr = fmt.Errorf("%w: %w", outerErr, err)
continue
}
defer cli.Close()

_, err = cli.Info(ctx)
if err != nil {
outerErr = fmt.Errorf("%w: %w", outerErr, err)
continue
}

return dockerHost
}

Expand Down

0 comments on commit 19fb55b

Please sign in to comment.