docker

package
v0.0.0-...-6a3711f Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListAdvertiseAddrs

func ListAdvertiseAddrs() ([]string, error)

ListAdvertiseAddrs returns non-loopback IPv4 addresses suitable for swarm advertise-addr.

func ServiceList

func ServiceList(exec *Executor, stackName string) ([]string, error)

ServiceList lists service names in a stack, returning only the bare service name (without the "<stack>_" prefix).

func ServiceRemove

func ServiceRemove(exec *Executor, serviceNames []string) error

ServiceRemove removes specific services by their full Docker service names (<stack>_<service>).

func StackBuild

func StackBuild(exec *Executor, contextPath, target, tag string) error

StackBuild builds a service image from a Dockerfile.

func StackDeploy

func StackDeploy(exec *Executor, stackName string, composeData []byte) error

StackDeploy deploys a stack from compose YAML data.

func StackRemove

func StackRemove(exec *Executor, stackName string) error

StackRemove removes a deployed stack.

func SwarmInit

func SwarmInit(exec *Executor) error

SwarmInit initializes a Docker swarm, auto-selecting the best advertise address.

func SwarmInitWithAddr

func SwarmInitWithAddr(exec *Executor, addr string) error

SwarmInitWithAddr initializes a Docker swarm with a specific advertise address.

func VolumeList

func VolumeList(exec *Executor, stackName string) ([]string, error)

VolumeList lists volumes with an optional filter.

func VolumeRemove

func VolumeRemove(exec *Executor, volumes []string) error

VolumeRemove removes the specified volumes.

Types

type Client

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

Client wraps the Docker SDK client for query operations.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new Docker SDK client.

func (*Client) Close

func (c *Client) Close() error

Close releases the Docker client resources.

func (*Client) IsStackRunning

func (c *Client) IsStackRunning(ctx context.Context, stackName string) (bool, error)

IsStackRunning checks if any services for the stack are deployed.

func (*Client) ListStackServices

func (c *Client) ListStackServices(ctx context.Context, stackName string) ([]swarm.Service, error)

ListStackServices lists services belonging to a stack, using server-side label filtering to avoid fetching all services on large swarms.

func (*Client) Ping

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

Ping checks if Docker is reachable.

func (*Client) SwarmStatus

func (c *Client) SwarmStatus(ctx context.Context) (swarm.LocalNodeState, error)

SwarmStatus returns the current node's swarm state.

type Executor

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

Executor runs docker CLI commands, handling sudo as needed.

func NewExecutor

func NewExecutor(sudoMode string) (*Executor, error)

NewExecutor creates an Executor that auto-detects sudo requirement or uses the configured preference.

func (*Executor) NeedsSudo

func (e *Executor) NeedsSudo() bool

NeedsSudo reports whether the executor uses sudo for commands.

func (*Executor) Ping

func (e *Executor) Ping() error

Ping checks whether the Docker daemon is reachable via the CLI.

func (*Executor) Run

func (e *Executor) Run(args ...string) (string, error)

Run executes a docker CLI command and returns stdout.

func (*Executor) RunPassthrough

func (e *Executor) RunPassthrough(args ...string) error

RunPassthrough executes a docker command with stdout/stderr connected to the terminal.

func (*Executor) RunWithStdin

func (e *Executor) RunWithStdin(input []byte, args ...string) error

RunWithStdin executes a docker command passing data via stdin.

func (*Executor) SwarmActive

func (e *Executor) SwarmActive() (bool, error)

SwarmActive checks whether Docker Swarm is active via the CLI.

Jump to

Keyboard shortcuts

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