agent/dockerclient/sdkclientfactory/sdkclientfactory.go
func findDockerVersions(ctx context.Context, endpoint string) map[dockerclient.DockerVersion]sdkclient.Client {
	// if the client version returns a MinAPIVersion, use it to return all the
	// Docker clients between MinAPIVersion and APIVersion, else try pinging
	// the clients in getKnownAPIVersions
	var minAPIVersion, apiVersion string
	// get a Docker client with the default supported version
	client, err := newVersionedClient(endpoint, string(minDockerAPIVersion))
	if err == nil {
		derivedCtx, cancel := context.WithTimeout(ctx, dockerclient.VersionTimeout)
		defer cancel()
		serverVersion, err := client.ServerVersion(derivedCtx)
		if err == nil {
			apiVersion = serverVersion.APIVersion
			// check if the docker.Version has MinAPIVersion value
			if serverVersion.MinAPIVersion != "" {
				minAPIVersion = serverVersion.MinAPIVersion
			}
		}
	}
	clients := make(map[dockerclient.DockerVersion]sdkclient.Client)
	for _, version := range dockerclient.GetKnownAPIVersions() {
		dockerClient, err := getDockerClientForVersion(endpoint, string(version), minAPIVersion, apiVersion, ctx)
		if err != nil {
			log.Infof("Unable to get Docker client for version %s: %v", version, err)
			continue
		}
		clients[version] = dockerClient
	}
	return clients
}
func findDockerVersions(ctx context.Context, endpoint string) map[dockerclient.DockerVersion]sdkclient.Client {
	// if the client version returns a MinAPIVersion, use it to return all the
	// Docker clients between MinAPIVersion and APIVersion, else try pinging
	// the clients in getKnownAPIVersions
	var minAPIVersion, apiVersion string
	// get a Docker client with the default supported version
	client, err := newVersionedClient(endpoint, string(minDockerAPIVersion))
	if err == nil {
		derivedCtx, cancel := context.WithTimeout(ctx, dockerclient.VersionTimeout)
		defer cancel()
		serverVersion, err := client.ServerVersion(derivedCtx)
		if err == nil {
			apiVersion = serverVersion.APIVersion
			// check if the docker.Version has MinAPIVersion value
			if serverVersion.MinAPIVersion != "" {
				minAPIVersion = serverVersion.MinAPIVersion
			}
		}
	}
	clients := make(map[dockerclient.DockerVersion]sdkclient.Client)
	for _, version := range dockerclient.GetKnownAPIVersions() {
		dockerClient, err := getDockerClientForVersion(endpoint, string(version), minAPIVersion, apiVersion, ctx)
		if err != nil {
			log.Infof("Unable to get Docker client for version %s: %v", version, err)
			continue
		}
		clients[version] = dockerClient
	}
	return clients
}
// findDockerVersions loops over all known API versions and finds which ones
// are supported by the docker daemon on the host