dockerctl

package
v0.24.6 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dockerctl is a minimal Docker Engine API client over the local unix socket, enough for the index-sync cycle to quiesce and restart the compose brain service: find one container by compose labels, stop it, start it, inspect its running/health state. Stdlib only — the full docker SDK is a heavy dependency for four endpoints (go-research: reuse first, but YAGNI).

Index

Constants

View Source
const DefaultSocket = "/var/run/docker.sock"

DefaultSocket is the Docker daemon socket path mounted into the loop service.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the Docker Engine API.

func New

func New(socket string) *Client

New returns a client bound to a unix socket (DefaultSocket when empty).

func NewHTTP

func NewHTTP(base string, hc *http.Client) (*Client, error)

NewHTTP returns a client against a concrete base URL with a caller HTTP client. Used by tests against an httptest server (real HTTP).

func (*Client) FindOne

func (c *Client) FindOne(ctx context.Context, labels map[string]string) (string, error)

FindOne returns the id of the single container matching every label (key=value). Zero or several matches is an error: the loop must target one deterministic container.

func (*Client) Inspect

func (c *Client) Inspect(ctx context.Context, id string) (running bool, health string, err error)

Inspect reports whether the container is running and its health status (empty when the container declares no healthcheck).

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping reports whether the daemon answers /_ping.

func (*Client) Start

func (c *Client) Start(ctx context.Context, id string) error

Start starts a container. 304 (already running) is success.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context, id string, timeoutSec int) error

Stop stops a container, waiting up to timeoutSec for it to exit.

func (*Client) WaitHealthy

func (c *Client) WaitHealthy(ctx context.Context, id string, timeout time.Duration) error

WaitHealthy polls Inspect until the container is running (and healthy when it declares a healthcheck) or the deadline passes.

Jump to

Keyboard shortcuts

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