vxcontrol/pentagi · critical

failed to get docker info: %w

Error message

failed to get docker info: %w

What it means

NewDockerClient builds a moby client from the environment and immediately calls cli.Info(ctx) as a health check that the Docker daemon is reachable and answering API requests. If that call fails (daemon down, wrong DOCKER_HOST, permission denied on the socket, API version mismatch), the constructor aborts and wraps the underlying error with "failed to get docker info: %w". It is the earliest signal that PentAGI cannot talk to a Docker daemon at all.

Source

Thrown at backend/pkg/docker/client.go:129

		portsBase = BaseContainerPortsNumber
	}
	ports := make([]int, containerPortsNumber)
	for i := range containerPortsNumber {
		delta := (int(flowID)*containerPortsNumber + i) % limitContainerPortsNumber
		ports[i] = portsBase + delta
	}
	return ports
}

func NewDockerClient(ctx context.Context, db database.Querier, cfg *config.Config) (DockerClient, error) {
	cli, err := client.New(client.FromEnv)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize docker client: %w", err)
	}

	infoResult, err := cli.Info(ctx, client.InfoOptions{})
	if err != nil {
		return nil, fmt.Errorf("failed to get docker info: %w", err)
	}
	info := infoResult.Info

	// Resolve which host socket (if any) gets bind-mounted into worker containers.
	// Autodetection is skipped when DOCKER_INSIDE_HOST designates a daemon
	// endpoint for sandboxes: mounting the host socket alongside it would grant an
	// agent control of the daemon running PentAGI itself.
	socket, autodetectSocket := cfg.WorkerDockerSocket()
	if autodetectSocket {
		socket = getHostDockerSocket(ctx, cli)
	}
	inside := cfg.DockerInside
	if inside {
		switch {
		case cfg.DockerSocket != "":
			logrus.Infof("DOCKER_INSIDE=true: worker containers will be given Docker access "+
				"via the configured socket %q.", cfg.DockerSocket)
		case cfg.DockerInsideHost != "":

View on GitHub (pinned to ea665308ba)

Solutions

  1. Verify the daemon is up: run 'docker info' with the same environment (same user, same DOCKER_HOST); fix the daemon if it fails.
  2. Check DOCKER_HOST / DOCKER_SOCKET env vars and the mounted /var/run/docker.sock when running inside a container; mount the socket or set DOCKER_HOST correctly.
  3. Fix socket permissions: add the user to the 'docker' group (usermod -aG docker $USER) or use rootless socket at /run/user/$UID/docker.sock.
  4. If API version mismatch, set DOCKER_API_VERSION to the daemon's version or upgrade the daemon/client.
  5. Restart dockerd (systemctl restart docker) after config or certificate changes.

Example fix

// before
export DOCKER_HOST=tcp://127.0.0.1:2375  # daemon not listening there
// after
export DOCKER_HOST=unix:///var/run/docker.sock  # or unset to use default socket
Defensive patterns

Strategy: validation

Validate before calling

// Before constructing the client (or as a health gate):
cli, err := client.New(client.FromEnv)
if err != nil { return err }
if _, err := cli.Info(ctx, client.InfoOptions{}); err != nil {
    return fmt.Errorf("docker daemon unreachable (%v): check DOCKER_HOST and /var/run/docker.sock", err)
}

Try / catch

if _, err := NewDockerClient(ctx, db, cfg); err != nil {
    if strings.Contains(err.Error(), "failed to get docker info") {
        log.Fatalf("Docker daemon not reachable: %v — start dockerd or fix DOCKER_HOST", err)
    }
    return err
}

Prevention

When it happens

Trigger: client.New(client.FromEnv) succeeded (so a socket path was resolved) but cli.Info() returned an error: Docker daemon not running, DOCKER_HOST points at an unreachable TCP endpoint, the user lacks read/write permission on /var/run/docker.sock, or the daemon's API version is incompatible with the moby client.

Common situations: Running PentAGI outside Docker Compose without a local dockerd; running the container without mounting /var/run/docker.sock; DOCKER_HOST=tcp://... pointing at a daemon behind a firewall or TLS misconfiguration; running as a non-root user not in the 'docker' group; Rootless Docker or podman socket env vars not exported (DOCKER_HOST unset in a systemd service context).

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/06f38bd19b3b3ee2. Report an issue: GitHub.