func parseDockerDaemonHost(addr string) (string, error) {
	addrParts := strings.Split(addr, "://")
	if len(addrParts) == 1 && addrParts[0] != "" {
		addrParts = []string{"tcp", addrParts[0]}
	}
	switch addrParts[0] {
	case "tcp":
		return parseTCPAddr(addrParts[1], DefaultTCPHost)
	case "unix":
		return parseSimpleProtoAddr("unix", addrParts[1], DefaultUnixSocket)
	case "npipe":
		return parseSimpleProtoAddr("npipe", addrParts[1], DefaultNamedPipe)
	case "fd":
		return addr, nil
	default:
		return "", fmt.Errorf("Invalid bind address format: %s", addr)
	}
}
parseDockerDaemonHost parses the specified address and returns an address that will be used as the host.
Depending of the address specified, this may return one of the global Default* strings defined in hosts.go.
package opts
import (
	"fmt"
	"net"
	"net/url"
	"strconv"
	"strings"
)
var (
	DefaultHTTPPort = 2375  
	DefaultTLSHTTPPort = 2376  
	DefaultUnixSocket = "/var/run/docker.sock"
	DefaultTCPHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultHTTPPort)
	DefaultTLSHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultTLSHTTPPort)
	DefaultNamedPipe = ` 
)
func ValidateHost(val string) (string, error) {
	host := strings.TrimSpace(val)
	if host != "" {
		_, err := parseDockerDaemonHost(host)
		if err != nil {
			return val, err
		}
	}
	return val, nil
}
func ParseHost(defaultToTLS bool, val string) (string, error) {
	host := strings.TrimSpace(val)
	if host == "" {
		if defaultToTLS {
			host = DefaultTLSHost
		} else {
			host = DefaultHost
		}
	} else {
		var err error
		host, err = parseDockerDaemonHost(host)
		if err != nil {
			return val, err
		}
	}
	return host, nil
}