runtime

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package runtime detects the local container runtime (Docker, OrbStack, Podman) and reports its name, binary path, version, and enterprise-mode hint.

nSelf supports any container runtime that exposes a Docker-compatible CLI. Detection probes binaries in priority order (docker, orb, podman) and uses the first one found on PATH. Callers should use Runtime.Binary instead of hardcoding "docker" so OrbStack and Podman users get first-class support.

Index

Constants

View Source
const (
	NameDocker   = "docker"
	NameOrbStack = "orbstack"
	NamePodman   = "podman"
)

Name constants for the supported runtimes. Stored on Runtime.Name so callers can branch on a known set instead of parsing strings.

Variables

View Source
var ErrNoRuntime = errors.New("no container runtime found (install docker, orbstack, or podman)")

ErrNoRuntime is returned by Detect when no supported container runtime is found on PATH.

Functions

This section is empty.

Types

type Runtime

type Runtime struct {
	// Name is one of NameDocker, NameOrbStack, NamePodman.
	Name string `json:"name"`
	// Binary is the absolute path to the runtime's CLI executable. Use this
	// instead of hardcoding "docker" when invoking exec.Command.
	Binary string `json:"binary"`
	// Version is the runtime's reported version string (e.g., "24.0.6").
	// Empty when the version probe fails; detection still succeeds in that case.
	Version string `json:"version"`
	// IsEnterprise is true when the runtime is Docker Desktop running with an
	// enterprise (paid) plan. Used to surface a license-compliance warning for
	// organizations >250 employees.
	IsEnterprise bool `json:"is_enterprise"`
}

Runtime describes a detected container runtime.

func Detect

func Detect() (*Runtime, error)

Detect probes PATH for a supported container runtime and returns a populated Runtime on success. It uses a 5-second timeout when probing version and enterprise mode so a stuck daemon does not hang the caller.

func DetectContext

func DetectContext(ctx context.Context) (*Runtime, error)

DetectContext is the context-aware variant of Detect. Callers running inside a wider operation (e.g., nself doctor) should pass their own context so the probe respects upstream cancellation.

func (*Runtime) EnterpriseWarning

func (r *Runtime) EnterpriseWarning() string

EnterpriseWarning returns a human-readable warning string for organizations running Docker Desktop's enterprise tier without a paid subscription. Empty when no warning applies.

func (*Runtime) String

func (r *Runtime) String() string

String renders a one-line summary suitable for `nself doctor --runtime`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL