docker

package
v0.0.0-...-d8c4ca1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the Docker client with our business logic

func NewClient

func NewClient(defaultTags []string) (*Client, error)

NewClient creates a new Docker client

func (*Client) Close

func (c *Client) Close() error

Close closes the Docker client

func (*Client) ContainerLogsTail

func (c *Client) ContainerLogsTail(ctx context.Context, containerID string, n int) ([]string, int, error)

ContainerLogsTail returns the last n log lines of a container plus the total captured byte size, reading both stdout and stderr.

func (*Client) ContainerStats

func (c *Client) ContainerStats(ctx context.Context, containerID string) (ContainerStatsSample, error)

ContainerStats reads a single (non-streaming) docker stats sample for a container via the one-shot stats endpoint. It is read-only and used only by the optional cloud module. PreCPUStats is intentionally ignored — it is zero for a one-shot read, so CPU percentages are computed by the caller across successive samples.

func (*Client) EngineID

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

EngineID returns the docker engine ID — the stable host fingerprint and the cloud's billable unit. Persisted by dockerd; survives reboots/reinstalls.

func (*Client) GetCloudContainers

func (c *Client) GetCloudContainers(ctx context.Context) ([]*apptypes.ContainerService, error)

GetCloudContainers lists docktail-managed containers for cloud reporting, INCLUDING stopped/exited ones — unlike GetEnabledContainers, which is running-only because the serve reconciler must never target a dead container. Reporting stopped containers lets the cloud render them as down rather than dropping them, and reserves "removed" for containers that truly leave Docker.

Running containers are parsed at full fidelity (multiple/indexed services and funnel included). A non-running container whose live parse fails — direct mode needs a running IP — falls back to a minimal entry keyed by the same primary service name it carries when running, so it stays in the catalog as a down service instead of being seen as removed. Limitation: a stopped container that declares multiple indexed services reports only its primary service until it is running again.

func (*Client) GetEnabledContainers

func (c *Client) GetEnabledContainers(ctx context.Context) ([]*apptypes.ContainerService, error)

GetEnabledContainers returns all running containers managed by DockTail. A container can be managed by a Tailscale service, a funnel, or both.

func (*Client) GetOtherContainers

func (c *Client) GetOtherContainers(ctx context.Context) ([]OtherContainer, error)

GetOtherContainers lists every container that is NOT a docktail-managed service (neither docktail.enable nor docktail.funnel.enable set), INCLUDING stopped ones, for the cloud's container-inventory view. It is read-only and builds each entry straight from the container-list summary — no per-container inspect — so it stays cheap even on a busy host. Used only by the cloud module (DOCKTAIL_CLOUD_KEY set); docktail-managed containers are reported separately by GetCloudContainers as services.

func (*Client) HostSpecs

func (c *Client) HostSpecs(ctx context.Context) HostSpec

HostSpecs reads static host capacity from `docker info` (best-effort; zero values on error). Read once at agent start — these do not change at runtime.

func (*Client) Hostname

func (c *Client) Hostname(ctx context.Context) string

Hostname returns the host's name as docker reports it (display-only).

func (*Client) InspectCloud

func (c *Client) InspectCloud(ctx context.Context, containerID string) (CloudInfo, error)

InspectCloud inspects a container and extracts the runtime fields the cloud catalog wants. It is read-only.

func (*Client) RestartCount

func (c *Client) RestartCount(ctx context.Context, containerID string) int

RestartCount best-effort reads a container's live restart count via inspect.

func (*Client) ServerVersion

func (c *Client) ServerVersion(ctx context.Context) string

ServerVersion returns the docker server version string (best-effort).

func (*Client) WatchEvents

func (c *Client) WatchEvents(ctx context.Context) (<-chan events.Message, <-chan error)

WatchEvents streams Docker container events

type CloudInfo

type CloudInfo struct {
	Image          string
	ImageTag       string
	State          string // running/exited/restarting/paused/created
	Health         string // healthy/unhealthy/starting (empty if no healthcheck)
	RestartCount   int
	ComposeProject string
	ComposeService string
	Networks       []string
}

CloudInfo is the runtime enrichment the cloud catalog needs that the reconciler's ContainerService does not already carry.

type ContainerStatsSample

type ContainerStatsSample struct {
	CPUTotalUsage  uint64 // cumulative container CPU time (ns)
	CPUSystemUsage uint64 // cumulative host CPU time (ns)
	OnlineCPUs     uint64 // CPUs available, for percentage normalization
	MemUsageBytes  int64  // working set: usage minus inactive file cache
	MemLimitBytes  int64  // effective limit: container limit, else host total
}

ContainerStatsSample is a single one-shot resource reading for a container. CPU is reported as the raw cumulative counters docker exposes; a percentage is the delta between two samples, so the caller keeps the previous one. Memory is the cache-adjusted working set and its effective limit, both ready to use directly.

type HostSpec

type HostSpec struct {
	OS            string
	KernelVersion string
	Arch          string
	CPUCores      int
	MemTotalBytes int64
}

HostSpec is static host capacity read once from `docker info` (display-only).

type OtherContainer

type OtherContainer struct {
	ID             string // short container id — identity within the host
	IsAgent        bool   // this container is running the reporting DockTail agent
	Name           string
	Image          string
	ImageTag       string
	State          string // running/exited/restarting/paused/created
	Status         string // human status line, e.g. "Up 3 hours (healthy)"
	Health         string // healthy/unhealthy/starting (best-effort, parsed from Status)
	ComposeProject string
	ComposeService string
	Ports          []string
	CreatedAt      int64 // unix seconds the container was created
}

OtherContainer is a NON-docktail container as seen for cloud reporting: limited, read-only metadata only. It carries no exec/deploy surface and is never health-checked — the cloud renders it as plain inventory alongside the monitored services.

Jump to

Keyboard shortcuts

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