Skip to content

Support configuring container engine socket path via config file #4612

@kantord

Description

@kantord

Current Behavior

Socket paths can only be overridden via environment variables:

  • TOOLHIVE_DOCKER_SOCKET
  • TOOLHIVE_PODMAN_SOCKET
  • TOOLHIVE_COLIMA_SOCKET

These are checked in pkg/container/docker/sdk/client_unix.go before falling back to auto-detection of standard socket locations. There is no way to persist this configuration in the ToolHive config file (~/.config/toolhive/config.yaml), meaning users with non-standard socket paths must set environment variables in every shell session or wrapper script.

Proposed Change

Add socket path fields to the Config struct in pkg/config/config.go, allowing users to configure them once via thv config or by editing the YAML file directly:

container_runtime:
  docker_socket: /run/user/1000/docker.sock
  podman_socket: /run/user/1000/podman/podman.sock
  colima_socket: /home/user/.colima/custom/docker.sock

Socket resolution in findPlatformContainerSocket would check sources in this order, preserving existing precedence:

  1. Environment variable (existing)
  2. Config file (new)
  3. Auto-detection of standard paths (existing)

Motivation

Configuring environment variables across GUI and CLI apps can be a bad experience, because there are various ways env variables can be set up, and not all of them are accessible by both GUI and CLI processes - it can actually even depend on how the process is launched.

Misconfiguration is hard to spot, but can lead to confusing, unexpected experiences. This is not user friendly, because users should not need to have a deep understanding of how their operating system handles environment variables across different ways of launching apps just to be able to use ToolHive.

See [this Discord thread for a concrete user report that illustrates the problem.

Metadata

Metadata

Assignees

Labels

cliChanges that impact CLI functionalityenhancementNew feature or request
No fields configured for Story 🗺️.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions