docker

package
v1.39.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package docker provides a fleet.Probe implementation that discovers running containers via the local Docker Engine unix socket using raw HTTP/1.1. No github.com/docker/docker SDK is used — stdlib net, net/http, bufio, encoding/json only.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSocketUnavailable is returned when the Driver cannot connect to the
	// Docker Engine unix socket (ENOENT, ECONNREFUSED, etc.).
	ErrSocketUnavailable = errors.New("fleet/docker: socket unavailable")

	// ErrEngineError is returned when the Docker Engine responds with a non-2xx
	// status, returns invalid JSON, or the response body exceeds the size cap.
	ErrEngineError = errors.New("fleet/docker: engine returned error")

	// ErrInvalidFilter is returned when Filter.Service contains characters
	// outside [a-zA-Z0-9._-]. Validated before any network call.
	ErrInvalidFilter = errors.New("fleet/docker: invalid filter")
)

Sentinel errors exposed for callers to errors.Is against.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is the Docker-socket fleet.Probe implementation. It communicates with the local Docker Engine via raw HTTP/1.1 over the unix socket — no github.com/docker/docker SDK dependency.

Driver implements fleet.Probe. Scheme() returns "docker". The alias "local" → docker driver is the caller's concern (P5).

func New

func New(opts ...Option) *Driver

New constructs a Driver with the given options. Callers may use New() with no arguments for the default configuration (socket=/var/run/docker.sock, timeout=10s).

func (*Driver) List

List queries the Docker Engine for running containers and maps them to fleet.RuntimeImage values.

Filter.Labels is intentionally ignored for MVP. Per the fleet.Filter spec, drivers may omit label matching; P5 wiring handles higher-level filtering.

func (*Driver) Scheme

func (d *Driver) Scheme() string

Scheme returns "docker". The alias "local" → docker driver is wired by the Registry caller (P5); this Driver only registers under its canonical scheme.

type Option

type Option func(*Driver)

Option configures a Driver.

func WithDialer

func WithDialer(fn func(ctx context.Context, network, addr string) (net.Conn, error)) Option

WithDialer overrides the unix-socket dialer. Tests inject net.Pipe-backed fakes here to avoid touching the real /var/run/docker.sock.

func WithSocketPath

func WithSocketPath(path string) Option

WithSocketPath overrides the default /var/run/docker.sock. No os.Getenv is used inside this package; socket path must come via this option.

func WithTimeout

func WithTimeout(duration time.Duration) Option

WithTimeout sets the per-request timeout. Default 10s.

Jump to

Keyboard shortcuts

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