vectordotdev/vector · error

$DOCKER_HOST is not a socket path

Error message

$DOCKER_HOST is not a socket path

What it means

vdev's detect_docker_socket() resolves the Docker socket path. If DOCKER_HOST is set, it must be a Unix domain socket URL with the unix:// prefix; any other scheme (tcp://, npipe://, ssh://, or a bare path) causes this panic because strip_prefix("unix://") returns None. The tool only supports local socket-based Docker endpoints.

Solutions

  1. Unset DOCKER_HOST so the default /var/run/docker.sock is used, provided Docker runs locally
  2. Rewrite DOCKER_HOST to the unix socket form, e.g. DOCKER_HOST=unix:///var/run/docker.sock
  3. For a remote/TCP daemon, start a local Docker daemon or expose the remote socket locally (e.g. via SSH tunnel to a unix socket) since vdev only supports unix:// sockets
  4. Verify with `echo $DOCKER_HOST` and `docker context show` that the active context is a local unix-socket endpoint

Example fix

// before
export DOCKER_HOST=tcp://127.0.0.1:2375
cargo vdev int start aws
// after
unset DOCKER_HOST
cargo vdev int start aws
Defensive patterns

Strategy: validation

Validate before calling

if [[ -n "$DOCKER_HOST" && "$DOCKER_HOST" != unix://* ]]; then echo "DOCKER_HOST must start with unix:// (got: $DOCKER_HOST)"; exit 1; fi

Type guard

function isUnixSocketHost(host: string): boolean { return host.startsWith('unix://'); }

Prevention

When it happens

Trigger: Running any vdev command that touches Docker (integration tests, container management) with DOCKER_HOST set to a non-unix:// value, e.g. DOCKER_HOST=tcp://127.0.0.1:2375, DOCKER_HOST=ssh://user@host, or DOCKER_HOST=/var/run/docker.sock (missing prefix).

Common situations: Developers using Docker over TCP or a remote Docker context (docker context use to a remote/TCP host), Docker Desktop on Windows/macOS exporting npipe:// or unix:// variants, or CI environments exporting DOCKER_HOST pointing at a remote daemon (e.g. dind over TCP).

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/f554c8434fd2b8b1. Report an issue: GitHub.

Appendix: source

Thrown at vdev/src/testing/docker.rs:42

            .stdout(Stdio::null())
            .stderr(Stdio::null())
            .spawn()
            .and_then(|mut child| child.wait())
            .is_ok_and(|status| status.success())
        {
            return OsString::from(String::from(tool));
        }
    }
    fatal!("No container tool could be detected.");
}

fn detect_docker_socket() -> PathBuf {
    match env::var_os("DOCKER_HOST") {
        Some(host) => host
            .into_string()
            .expect("Invalid value in $DOCKER_HOST")
            .strip_prefix("unix://")
            .expect("$DOCKER_HOST is not a socket path")
            .into(),
        None => "/var/run/docker.sock".into(),
    }
}

View on GitHub (pinned to bdb87aeaa4)