docker

package
v1.10.25 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Overview

Package docker is the sole adapter over the Docker SDK, keeping SDK types out of the rest of the codebase.

Index

Constants

View Source
const (
	ConfigWorkspaceLabel = "io.miabi.workspace"
	ConfigNameLabel      = "io.miabi.config"
	ConfigKeyLabel       = "io.miabi.config-key"
	ConfigDigestLabel    = "io.miabi.digest"
)

Ownership is on the object itself so GC and re-import need not consult the DB.

View Source
const (
	// MinAPIVersion is the SDK's hard technical floor, distinct from the supported MinEngineVersion.
	MinAPIVersion = "1.40"
	// MinEngineVersion is the supported floor (CI matrix 25-29), quoted by the README, installer and Nodes badge.
	MinEngineVersion = "25.0"
)
View Source
const (
	LabelPrefix            = stackdocker.LabelPrefix
	LabelApp               = stackdocker.LabelApp
	LabelDeployment        = stackdocker.LabelDeployment
	LabelDatabase          = stackdocker.LabelDatabase
	LabelStack             = stackdocker.LabelStack
	LabelVolume            = stackdocker.LabelVolume
	LabelJob               = stackdocker.LabelJob
	LabelRole              = stackdocker.LabelRole
	LabelNode              = stackdocker.LabelNode
	LabelWorkspace         = stackdocker.LabelWorkspace
	LabelManaged           = stackdocker.LabelManaged
	LabelPipelineRun       = stackdocker.LabelPipelineRun
	LabelSizeBytes         = stackdocker.LabelSizeBytes
	LabelPartOf            = stackdocker.LabelPartOf
	LabelManagedBy         = stackdocker.LabelManagedBy
	LabelProtected         = stackdocker.LabelProtected
	LabelSpecHash          = stackdocker.LabelSpecHash
	RoleControlPlane       = stackdocker.RoleControlPlane
	RolePlatformDB         = stackdocker.RolePlatformDB
	RolePlatformCache      = stackdocker.RolePlatformCache
	RoleGateway            = stackdocker.RoleGateway
	RoleAgent              = stackdocker.RoleAgent
	RoleControlPlaneWorker = stackdocker.RoleControlPlaneWorker
	RoleNodeGateway        = stackdocker.RoleNodeGateway
	RoleNodeGatewayRedis   = stackdocker.RoleNodeGatewayRedis
	RolePlatformInternal   = stackdocker.RolePlatformInternal
	RoleProxyNetwork       = stackdocker.RoleProxyNetwork
	RoleMetadataGuard      = stackdocker.RoleMetadataGuard
	RoleRegistry           = stackdocker.RoleRegistry
	RoleRegistryGC         = stackdocker.RoleRegistryGC
	ManagedByCompose       = stackdocker.ManagedByCompose
	ManagedByMiabi         = stackdocker.ManagedByMiabi
	ManagedByExternal      = stackdocker.ManagedByExternal
	PartOfMiabi            = stackdocker.PartOfMiabi
	ManagedLabel           = stackdocker.ManagedLabel
)
View Source
const SwarmServiceNameLabel = "com.docker.swarm.service.name"

Swarm recreates a task container the moment it is removed, so the service is what can be reclaimed.

Variables

View Source
var (
	PlatformLabels     = stackdocker.PlatformLabels
	IsPlatformStack    = stackdocker.IsPlatformStack
	IsProtected        = stackdocker.IsProtected
	ManagedBy          = stackdocker.ManagedBy
	LabelValue         = stackdocker.LabelValue
	IsManaged          = stackdocker.IsManaged
	IsPlatformInfra    = stackdocker.IsPlatformInfra
	IsPlatformNetwork  = stackdocker.IsPlatformNetwork
	IsReservedLabelKey = stackdocker.IsReservedLabelKey
	SanitizeUserLabels = stackdocker.SanitizeUserLabels
	WorkspaceID        = stackdocker.WorkspaceID
)
View Source
var ErrEngineTooOld = errors.New("docker: engine too old")

ErrEngineTooOld replaces the SDK's obscure error for daemons below MinAPIVersion.

View Source
var ErrNotFound = stackdocker.ErrNotFound

ErrNotFound is owned by the stack seam so both sides compare against one value.

Functions

func NetworkRefMatches added in v1.10.6

func NetworkRefMatches(n Network, ref string) bool

NetworkRefMatches accepts name, full id or short id, since a name-only guard is bypassed by passing the id.

Types

type Attached added in v1.10.9

type Attached interface {
	io.ReadWriter
	// CloseWrite ends the container's stdin, which is how a consumer like pg_restore learns the input is done.
	CloseWrite() error
	// Wait blocks until the container exits and returns its exit code.
	Wait(ctx context.Context) (int, error)
	// Stderr is the tail of what the container wrote to stderr.
	Stderr() string
	// Close detaches and removes the container.
	Close() error
}

type BindMount

type BindMount = stackdocker.BindMount

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type Capabilities added in v1.9.6

type Capabilities struct {
	APIVersion string `json:"api_version"`
	// EngineVersion is the daemon's reported server version (e.g. "27.5.1").
	EngineVersion string `json:"engine_version"`
	// OS / Arch are the daemon's platform ("linux", "x86_64"/"aarch64").
	OS           string `json:"os"`
	Arch         string `json:"arch"`
	SwarmActive  bool   `json:"swarm_active"`
	SwarmManager bool   `json:"swarm_manager"`
}

type Client

type Client interface {
	// Ping verifies the daemon is reachable.
	Ping(ctx context.Context) error
	// Info returns engine information.
	Info(ctx context.Context) (Info, error)
	Capabilities(ctx context.Context) (Capabilities, error)

	ListContainers(ctx context.Context, all bool) ([]Container, error)
	InspectContainer(ctx context.Context, id string) (Container, error)
	InspectContainerConfig(ctx context.Context, id string) (ContainerConfig, error)
	RunContainer(ctx context.Context, spec RunSpec) (string, error)
	StartContainer(ctx context.Context, id string) error
	StopContainer(ctx context.Context, id string, timeoutSeconds int) error
	RestartContainer(ctx context.Context, id string, timeoutSeconds int) error
	RemoveContainer(ctx context.Context, id string, force bool) error

	RunOneShot(ctx context.Context, spec RunSpec) (exitCode int, logs string, err error)

	RunOneShotStream(ctx context.Context, spec RunSpec, sink func(LogLine) error) (exitCode int, err error)

	ReadContainerFile(ctx context.Context, containerID, path string) ([]byte, error)

	// Closing the returned reader also removes the helper container.
	CopyFileFromVolume(ctx context.Context, volume, image, file string) (rc io.ReadCloser, size int64, err error)

	// image must already be present on the node.
	CopyToVolume(ctx context.Context, volume, image, name string, content io.Reader, size int64) error

	// DialNetwork uses an ephemeral socat relay over the engine connection, so it works tunneled without a host port.
	DialNetwork(ctx context.Context, network, image, host string, port int) (net.Conn, error)

	RunAttached(ctx context.Context, spec RunSpec) (Attached, error)

	// Images. auth may be nil for anonymous (public) pulls.
	PullImage(ctx context.Context, ref string, auth *RegistryAuth) error
	// TagImage adds target as an additional tag for the local source image.
	TagImage(ctx context.Context, source, target string) error
	// PushImage pushes a local image ref to its registry. auth may be nil.
	PushImage(ctx context.Context, ref string, auth *RegistryAuth) error
	BuildImage(ctx context.Context, contextDir, dockerfile, tag string, sink func(LogLine) error) error
	// InspectImage returns a local image's identity (ID + digest) and size.
	InspectImage(ctx context.Context, ref string) (ImageInspect, error)
	// ImageExists reports whether ref is present locally (no pull).
	ImageExists(ctx context.Context, ref string) (bool, error)
	RemoveImage(ctx context.Context, ref string, force bool) error

	// Prune* target only the safe set (dangling images, build cache); callers add their own managed-resource guards.
	ListImages(ctx context.Context) ([]Image, error)
	DiskUsage(ctx context.Context) (DiskUsage, error)
	VolumeUsage(ctx context.Context) ([]VolumeUsage, error)
	PruneImages(ctx context.Context, opts PruneImagesOptions) (PruneReport, error)
	PruneBuildCache(ctx context.Context) (PruneReport, error)

	StreamEvents(ctx context.Context, sink func(EngineEvent) error) error

	// Callers must Close the returned stream.
	Exec(ctx context.Context, containerID string, opts ExecOptions) (ExecStream, error)

	Top(ctx context.Context, containerID, psArgs string) (ProcessList, error)

	// The sink is invoked per item; return a non-nil error to stop.
	StreamLogs(ctx context.Context, id string, follow bool, tail string, sink func(LogLine) error) error
	StreamStats(ctx context.Context, id string, sink func(StatsSample) error) error
	// StatsOnce returns a single resource-usage sample.
	StatsOnce(ctx context.Context, id string) (StatsSample, error)

	EnsureNetwork(ctx context.Context, name string) (string, error)
	CreateNetwork(ctx context.Context, name, driver string, internal bool) (string, error)
	// CreateNetworkSpec errors if the name exists; EnsureNetworkSpec is the create-or-reuse variant.
	CreateNetworkSpec(ctx context.Context, spec NetworkSpec) (string, error)
	EnsureNetworkSpec(ctx context.Context, spec NetworkSpec) (string, error)
	RemoveNetwork(ctx context.Context, name string) error
	ListNetworks(ctx context.Context) ([]Network, error)
	// InspectNetwork returns ErrNotFound when the network does not exist.
	InspectNetwork(ctx context.Context, name string) (NetworkState, error)
	// Rootless reports whether the daemon runs in rootless mode.
	Rootless(ctx context.Context) (bool, error)
	// Both are idempotent; used to keep only route-exposed apps on the shared proxy network.
	NetworkConnect(ctx context.Context, name, containerID string, aliases []string) error
	NetworkDisconnect(ctx context.Context, name, containerID string, force bool) error
	CreateVolume(ctx context.Context, name string, labels map[string]string, sizeBytes int64) (Volume, error)
	CreateVolumeWith(ctx context.Context, spec VolumeSpec) (Volume, error)
	ListVolumes(ctx context.Context) ([]Volume, error)
	InspectVolume(ctx context.Context, name string) (Volume, error)
	RemoveVolume(ctx context.Context, name string, force bool) error

	// Users never run docker swarm/service themselves; all but Swarm need a reachable manager.
	Swarm(ctx context.Context) (SwarmInfo, error)
	SwarmInit(ctx context.Context, req SwarmInitRequest) (nodeID string, err error)
	SwarmJoin(ctx context.Context, req SwarmJoinRequest) error
	SwarmLeave(ctx context.Context, force bool) error
	SwarmJoinTokens(ctx context.Context) (SwarmJoinTokens, error)
	SwarmNodes(ctx context.Context) ([]SwarmNode, error)
	SwarmNodeRemove(ctx context.Context, nodeID string, force bool) error
	// Drain makes a node safe to reboot by rescheduling its tasks away.
	SwarmNodeAvailability(ctx context.Context, nodeID, availability string) error
	SwarmNodeSetLabel(ctx context.Context, nodeID, key, value string) error
	// Only the manager can list tasks: Miabi may hold no Docker client for the nodes.
	SwarmTasks(ctx context.Context, nodeID string) ([]SwarmTask, error)

	ServiceCreate(ctx context.Context, spec ServiceSpec) (id string, err error)
	ServiceUpdate(ctx context.Context, idOrName string, spec ServiceSpec) error
	ServiceRemove(ctx context.Context, idOrName string) error
	ServiceScale(ctx context.Context, idOrName string, replicas uint64) error
	ServiceSetEndpointMode(ctx context.Context, idOrName, mode string) error
	ServiceSetIngressNetwork(ctx context.Context, idOrName, network, alias string, attached bool) error
	ServiceInspect(ctx context.Context, idOrName string) (ServiceStatus, error)

	// Swarm config objects backing kind: Config on a replicated service.
	EnsureConfig(ctx context.Context, obj ConfigObject) (string, error)
	ListManagedConfigs(ctx context.Context) ([]ConfigInfo, error)
	RemoveConfig(ctx context.Context, id string) error
	ServiceList(ctx context.Context) ([]ServiceStatus, error)
	// ServiceRestart forces a rolling restart of a service's tasks in place.
	ServiceRestart(ctx context.Context, idOrName string) error
	ServiceTaskContainerID(ctx context.Context, serviceName string) (string, error)
	// ServiceEnv can carry secrets, so it is for the service layer to inspect, never to return to a client.
	ServiceEnv(ctx context.Context, idOrName string) ([]string, error)
	// StreamServiceLogs reads from the manager, the only way to reach tasks on nodes Miabi has no client for.
	StreamServiceLogs(ctx context.Context, serviceName string, follow bool, tail string, sink func(LogLine) error) error
	CreateOverlayNetwork(ctx context.Context, name string) (id string, err error)

	// Close releases the underlying connection.
	Close() error
}

Client is the abstraction the rest of the app depends on.

func New

func New() (Client, error)

func NewRemote

func NewRemote(dial DialFunc) (Client, error)

The dummy "http://" host makes the SDK speak plain HTTP over the tunnel stream.

func NewSocket

func NewSocket(host string) (Client, error)

func NewTCP

func NewTCP(host string, tlsm *TLSMaterial) (Client, error)

func Offline

func Offline(err error) Client

Offline lets callers resolve a client unconditionally; best-effort cleanups no-op on a disconnected node.

type ConfigInfo added in v1.8.1

type ConfigInfo struct {
	ID        string
	Name      string
	Workspace string
	Config    string
	CreatedAt time.Time
}

ConfigInfo is a published config object, as GC sees it.

type ConfigObject added in v1.8.1

type ConfigObject struct {
	Workspace string // workspace uid
	Config    string // config resource name
	Key       string // file key within the config
	Digest    string // digest12 of the projected file (content + mode)
	Content   string
}

ConfigObject is one docker config to publish for a swarm task.

func (ConfigObject) ObjectName added in v1.8.1

func (c ConfigObject) ObjectName() string

Content-addressed because docker configs are immutable; a change yields a new object.

type Container

type Container = stackdocker.Container

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type ContainerConfig

type ContainerConfig = stackdocker.ContainerConfig

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type ContainerMount

type ContainerMount = stackdocker.ContainerMount

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type ContainerNetwork

type ContainerNetwork = stackdocker.ContainerNetwork

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type DialFunc

type DialFunc func(ctx context.Context) (net.Conn, error)

Each Docker API request gets its own tunnel stream so streaming endpoints work.

type DiskUsage

type DiskUsage struct {
	Images     DiskUsageCategory `json:"images"`
	Containers DiskUsageCategory `json:"containers"`
	Volumes    DiskUsageCategory `json:"volumes"`
	BuildCache DiskUsageCategory `json:"build_cache"`
	// VolumeItems is free (the daemon walks the fs anyway) but unserialized; callers want totals.
	VolumeItems []VolumeUsage `json:"-"`
}

type DiskUsageCategory

type DiskUsageCategory struct {
	Count       int   `json:"count"`
	Active      int   `json:"active"`
	TotalBytes  int64 `json:"total_bytes"`
	Reclaimable int64 `json:"reclaimable_bytes"`
}

Reclaimable is an upper bound that ignores layer sharing, as `docker system df` reports it.

type EngineEvent

type EngineEvent struct {
	Action      string // start, die, oom, kill, stop, "health_status: healthy", ...
	ContainerID string
	Attributes  map[string]string
}

type ExecOptions

type ExecOptions struct {
	Cmd []string // command + args; e.g. ["/bin/sh"]
	Tty bool     // allocate a pseudo-TTY (raw, un-multiplexed stream)
	Env []string // extra environment, "KEY=VALUE"
}

ExecOptions configures an interactive command run inside a running container.

type ExecStream

type ExecStream interface {
	Read(p []byte) (int, error)
	Write(p []byte) (int, error)
	Resize(ctx context.Context, height, width uint) error
	Close() error
}

With a TTY the stream is raw (no stdcopy multiplexing).

type FileEntry added in v1.8.1

type FileEntry = stackdocker.FileEntry

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type GPURequest added in v1.2.0

type GPURequest = stackdocker.GPURequest

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type HealthcheckSpec

type HealthcheckSpec = stackdocker.HealthcheckSpec

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type Image

type Image struct {
	ID          string            `json:"id"`
	RepoTags    []string          `json:"repo_tags,omitempty"`
	RepoDigests []string          `json:"repo_digests,omitempty"`
	Size        int64             `json:"size"`
	SharedSize  int64             `json:"shared_size"`
	Created     int64             `json:"created"`
	Containers  int64             `json:"containers"` // -1 when the daemon did not compute it
	Dangling    bool              `json:"dangling"`   // untagged (<none>:<none>)
	Labels      map[string]string `json:"labels,omitempty"`
}

type ImageInspect

type ImageInspect struct {
	ID     string `json:"id"`     // content-addressable image ID (sha256:…)
	Digest string `json:"digest"` // repo digest when present, else the image ID
	Size   int64  `json:"size"`
}

ImageInspect Digest falls back to the image ID for a locally-built, never-pushed image.

type Info

type Info struct {
	// Name is the Docker host's hostname, not the Miabi container's.
	Name          string `json:"name"`
	Version       string `json:"version"`
	APIVersion    string `json:"api_version"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
	Containers    int    `json:"containers"`
	ContainersRun int    `json:"containers_running"`
	Images        int    `json:"images"`
	CPUs          int    `json:"cpus"`
	MemTotal      int64  `json:"mem_total"`
	// DataRoot's filesystem size is how a node's storage capacity is measured.
	DataRoot string `json:"data_root,omitempty"`
	// The "nvidia" runtime is present exactly when the NVIDIA Container Toolkit is installed.
	Runtimes []string `json:"runtimes,omitempty"`
}

Info summarizes the Docker engine.

type LogLine

type LogLine struct {
	Stream string `json:"stream"` // "stdout" | "stderr"
	Text   string `json:"text"`
}

LogLine is a single demultiplexed log line.

type Network

type Network struct {
	ID     string            `json:"id"`
	Name   string            `json:"name"`
	Driver string            `json:"driver"`
	Scope  string            `json:"scope"`
	Labels map[string]string `json:"labels,omitempty"`
	// Subnet lets the allocator reserve pool subnets already used by existing networks.
	Subnet  string `json:"subnet,omitempty"`
	Gateway string `json:"gateway,omitempty"`
	// EnableIPv6 is what the daemon reports, honest for networks created before Miabi set it explicitly.
	IPv6Subnet  string `json:"ipv6_subnet,omitempty"`
	IPv6Gateway string `json:"ipv6_gateway,omitempty"`
	EnableIPv6  bool   `json:"enable_ipv6"`
}

Network summarizes a Docker network.

type NetworkSpec

type NetworkSpec = stackdocker.NetworkSpec

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type NetworkState added in v1.10.22

type NetworkState = stackdocker.NetworkState

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type Port

type Port = stackdocker.Port

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type PortMapping

type PortMapping = stackdocker.PortMapping

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type ProcessList

type ProcessList struct {
	Titles    []string   `json:"titles"`
	Processes [][]string `json:"processes"`
}

type PruneImagesOptions

type PruneImagesOptions struct {
	Dangling bool
	Until    string
}

type PruneReport

type PruneReport struct {
	ItemsDeleted   []string `json:"items_deleted,omitempty"`
	SpaceReclaimed int64    `json:"space_reclaimed"`
}

PruneReport is the outcome of a prune: what was removed and the bytes freed.

type RegistryAuth

type RegistryAuth = stackdocker.RegistryAuth

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type RunSpec

type RunSpec = stackdocker.RunSpec

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type ServiceBind

type ServiceBind struct {
	Source   string // host path (present on every node)
	Target   string // container path
	ReadOnly bool
}

ServiceBind is a host-path bind mount for a swarm service task (mount.TypeBind).

type ServiceConfig added in v1.8.1

type ServiceConfig struct {
	ID   string
	Name string
	Path string
	Mode uint32
}

type ServiceMountDriver

type ServiceMountDriver struct {
	Name    string
	Options map[string]string
}

ServiceMountDriver makes every node materialize the same backing volume rather than an empty local one.

type ServiceSpec

type ServiceSpec struct {
	Name     string
	Image    string
	Env      []string // KEY=VALUE
	Cmd      []string // command args (ContainerSpec.Args); nil keeps the image default
	Replicas uint64   // 0 is treated as 1 (ignored when Global)
	// Global also covers nodes that join later, so a per-node daemon ships without touching each host.
	Global         bool
	Networks       []string          // swarm-scoped (overlay) network names to attach
	NetworkAliases []string          // DNS aliases applied on each attached network
	Mounts         map[string]string // volume name -> container path
	// Required for shared volumes on a service, or a task on another node silently gets an empty local volume.
	MountDrivers map[string]ServiceMountDriver
	// Binds need no driver config; the path is assumed present on every node a task lands on.
	Binds []ServiceBind
	// Swarm distributes configs over raft, so a task lands with its files on any node.
	Configs     []ServiceConfig
	Labels      map[string]string
	MemoryBytes int64
	NanoCPUs    int64
	Constraints []string
	Healthcheck *HealthcheckSpec
	User        string
	CapAdd      []string
	CapDrop     []string
	// NoNewPrivileges and ReadOnlyRootfs harden each task the way RunSpec hardens a container.
	NoNewPrivileges bool
	ReadOnlyRootfs  bool
	// Rolling update tuning (0 = Swarm defaults).
	UpdateParallelism uint64
	UpdateDelay       time.Duration
	// RegistryAuth is distributed to workers so their tasks can pull (like --with-registry-auth); nil if public.
	RegistryAuth *RegistryAuth
	// IngressNetwork is separate from Networks so tenant aliases never land on the shared overlay and collide.
	IngressNetwork string
	IngressAlias   string
	// EndpointMode "dnsrr" is for hosts that cannot program IPVS; default "vip".
	EndpointMode string
}

type ServiceStatus

type ServiceStatus struct {
	ID           string         `json:"id"`
	Name         string         `json:"name"`
	Image        string         `json:"image,omitempty"`
	Replicas     uint64         `json:"replicas"`      // desired
	RunningTasks uint64         `json:"running_tasks"` // currently running
	Placement    map[string]int `json:"placement,omitempty"`
	// StartedAt comes from the swarm control plane, so it is known even for nodes Miabi has no client for.
	StartedAt string `json:"started_at,omitempty"`
}

type StatsSample

type StatsSample struct {
	CPUPercent     float64 `json:"cpu_percent"`
	MemoryUsage    uint64  `json:"memory_usage_bytes"`
	MemoryLimit    uint64  `json:"memory_limit_bytes"`
	MemoryPercent  float64 `json:"memory_percent"`
	NetworkRxBytes uint64  `json:"network_rx_bytes"`
	NetworkTxBytes uint64  `json:"network_tx_bytes"`
}

StatsSample is a point-in-time resource usage sample for a container.

type SwarmInfo

type SwarmInfo struct {
	// "inactive" means plain (non-swarm) Docker.
	LocalNodeState   string `json:"local_node_state"`
	ControlAvailable bool   `json:"control_available"`
	// NodeAddr is advertised to peers and used as the join remote-address.
	NodeID   string `json:"node_id"`
	NodeAddr string `json:"node_addr"`
	// Managers / Nodes are cluster-wide counts (manager-reported; 0 elsewhere).
	Managers int `json:"managers"`
	Nodes    int `json:"nodes"`
	// RemoteManagers are the advertised addresses of the swarm's managers.
	RemoteManagers []string `json:"remote_managers,omitempty"`
	// Error carries the engine's swarm error string when LocalNodeState == error.
	Error string `json:"error,omitempty"`
}

SwarmInfo needs no manager role, so it is the cheap signal for auto-detecting cluster mode.

type SwarmInitRequest

type SwarmInitRequest struct {
	AdvertiseAddr string
	// ListenAddr is the management-plane bind; blank defaults to 0.0.0.0:2377.
	ListenAddr   string
	DataPathAddr string
}

SwarmInitRequest configures putting an engine into swarm mode as a manager.

type SwarmJoinRequest

type SwarmJoinRequest struct {
	// RemoteAddrs are the manager addresses to dial (host:port).
	RemoteAddrs []string
	// JoinToken is the worker or manager join token.
	JoinToken     string
	AdvertiseAddr string
	// ListenAddr is the management-plane bind; blank defaults to 0.0.0.0:2377.
	ListenAddr string
}

SwarmJoinRequest configures joining an engine to an existing swarm.

type SwarmJoinTokens

type SwarmJoinTokens struct {
	Worker  string `json:"worker"`
	Manager string `json:"manager"`
}

SwarmJoinTokens are the secrets a node uses to join a swarm in either role.

type SwarmNode

type SwarmNode struct {
	ID            string `json:"id"`
	Hostname      string `json:"hostname"`
	Role          string `json:"role"`         // manager | worker
	Availability  string `json:"availability"` // active | pause | drain
	State         string `json:"state"`        // ready | down | unknown | disconnected
	Leader        bool   `json:"leader"`
	Reachability  string `json:"reachability,omitempty"` // reachable | unreachable (managers)
	Addr          string `json:"addr,omitempty"`
	EngineVersion string `json:"engine_version,omitempty"`
	// Reported over the swarm control plane, so known even for nodes Miabi has no Docker client for.
	NanoCPUs    int64  `json:"nano_cpus,omitempty"`    // 1e9 == one core
	MemoryBytes int64  `json:"memory_bytes,omitempty"` // total, not used
	OS          string `json:"os,omitempty"`           // linux | windows
	Arch        string `json:"arch,omitempty"`         // x86_64 | aarch64 | …
	Tasks       int    `json:"tasks"`
}

SwarmNode is one node as seen from a swarm manager (`docker node ls`).

type SwarmTask added in v1.3.0

type SwarmTask struct {
	ID           string `json:"id"`
	ServiceName  string `json:"service_name"`
	NodeID       string `json:"node_id"`
	Image        string `json:"image,omitempty"`
	Slot         int    `json:"slot,omitempty"`
	State        string `json:"state"`         // running | preparing | failed | …
	DesiredState string `json:"desired_state"` // running | shutdown
	Message      string `json:"message,omitempty"`
	Err          string `json:"error,omitempty"`
	UpdatedAt    string `json:"updated_at,omitempty"` // RFC3339
}

Only a manager can enumerate tasks; the containers live on nodes Miabi may hold no client for.

type TLSMaterial

type TLSMaterial struct {
	CACert []byte
	Cert   []byte
	Key    []byte
}

TLSMaterial nil means plaintext; CACert alone verifies the server, Cert+Key add mTLS.

type Volume

type Volume = stackdocker.Volume

Aliased from the stack module because Client must use identical named types to satisfy stackdocker.Client.

type VolumeSpec

type VolumeSpec struct {
	Name       string
	Labels     map[string]string
	SizeBytes  int64
	Driver     string
	DriverOpts map[string]string
	// DevicePath keeps the volume an ordinary named Docker volume, so backup, housekeeping and mounts are unchanged.
	DevicePath string
}

VolumeSpec empty Driver uses Docker's local default; DriverOpts carry the NFS/CIFS mount options.

type VolumeUsage

type VolumeUsage struct {
	DockerName string `json:"docker_name"`
	Bytes      int64  `json:"bytes"`
	RefCount   int    `json:"ref_count"`
}

RefCount 0 means reclaimable.

Jump to

Keyboard shortcuts

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