docker/cli · error

invalid proto, expected

Error message

invalid proto, expected %s: %s

What it means

parseSimpleProtoAddr handles unix and npipe addresses. After stripping the expected proto:// prefix it rejects any value that still contains '://', i.e. a nested or repeated scheme such as unix://tcp://x. The address must be a plain socket path for the given proto.

Solutions

  1. Provide a single scheme: unix:///var/run/docker.sock or unix://path.
  2. Remove any nested '://' from the socket path.
  3. For Windows named pipes use npipe://./pipe/docker_engine.
  4. Validate that the address contains at most one '://' before calling parseSimpleProtoAddr.

Example fix

# before
docker -H unix://tcp://x ps

# after
docker -H unix:///var/run/docker.sock ps
Defensive patterns

Strategy: validation

Validate before calling

// Reject nested schemes for unix/npipe addresses.
func noNestedScheme(addr string) error {
    if strings.Count(addr, "://") > 1 {
        return fmt.Errorf("nested scheme in %q", addr)
    }
    return nil
}

Prevention

When it happens

Trigger: -H with a doubled or nested scheme for unix/npipe, e.g. -H unix://tcp://x, -H npipe://foo://bar, or otherwise embedding '://' inside a unix/npipe address.

Common situations: Chaining schemes by mistake; malformed socket path containing a colon-slash sequence; copy-paste mixing two -H examples.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/d16d709f844ddff2. Report an issue: GitHub.

Appendix: source

Thrown at opts/hosts.go:86

	case "npipe":
		return parseSimpleProtoAddr(proto, host, defaultNamedPipe)
	case "fd":
		return addr, nil
	case "ssh":
		return addr, nil
	default:
		return "", fmt.Errorf("invalid bind address format: %s", addr)
	}
}

// parseSimpleProtoAddr parses and validates that the specified address is a valid
// socket address for simple protocols like unix and npipe. It returns a formatted
// socket address, either using the address parsed from addr, or the contents of
// defaultAddr if addr is a blank string.
func parseSimpleProtoAddr(proto, addr, defaultAddr string) (string, error) {
	addr = strings.TrimPrefix(addr, proto+"://")
	if strings.Contains(addr, "://") {
		return "", fmt.Errorf("invalid proto, expected %s: %s", proto, addr)
	}
	if addr == "" {
		addr = defaultAddr
	}
	return fmt.Sprintf("%s://%s", proto, addr), nil
}

// ParseTCPAddr parses and validates that the specified address is a valid TCP
// address. It returns a formatted TCP address, either using the address parsed
// from tryAddr, or the contents of defaultAddr if tryAddr is a blank string.
// tryAddr is expected to have already been Trim()'d
// defaultAddr must be in the full `tcp://host:port` form
func ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) {
	if tryAddr == "" || tryAddr == "tcp://" {
		return defaultAddr, nil
	}
	addr := strings.TrimPrefix(tryAddr, "tcp://")
	if strings.Contains(addr, "://") || addr == "" {

View on GitHub (pinned to 4f84911bfe)