docker

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 10 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 Engine API client.

func New

func New(host string) (*Client, error)

New creates a new Docker client connecting to the given host. If host is empty, the DOCKER_HOST environment variable is used.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying Docker client connection.

func (*Client) ContainerWait

func (c *Client) ContainerWait(ctx context.Context, id string, condition container.WaitCondition) error

ContainerWait blocks until the container reaches the given condition.

func (*Client) Events

func (c *Client) Events(ctx context.Context, filters client.Filters) (<-chan events.Message, <-chan error)

Events subscribes to Docker events matching the given filters. Returns separate channels for messages and errors.

func (*Client) ExecInContainer

func (c *Client) ExecInContainer(ctx context.Context, containerID, command string) (int, error)

ExecInContainer runs a command inside a container and returns its exit code.

func (*Client) InspectContainer

func (c *Client) InspectContainer(ctx context.Context, id string) (*types.Container, error)

InspectContainer returns detailed information about a container, including mounts.

func (*Client) ListBackupContainers

func (c *Client) ListBackupContainers(ctx context.Context) ([]types.Container, error)

ListBackupContainers returns all running containers that have buoy.enabled=true.

func (*Client) ListContainersByProject

func (c *Client) ListContainersByProject(ctx context.Context, project string) ([]types.Container, error)

ListContainersByProject returns all containers belonging to the given compose project.

func (*Client) StartContainer

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

StartContainer starts a container.

func (*Client) StopContainer

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

StopContainer stops a container with the given timeout.

func (*Client) WatchContainer added in v0.1.2

func (c *Client) WatchContainer(ctx context.Context, containerID string, eventTypes ...string) (<-chan events.Message, <-chan error)

WatchContainer subscribes to Docker events for a specific container.

type Event

type Event struct {
	Type      EventType
	ID        string
	ActorName string
}

Event represents a Docker container lifecycle event.

type EventType

type EventType string

EventType represents the type of a Docker event.

const (
	EventStart   EventType = "start"
	EventDie     EventType = "die"
	EventDestroy EventType = "destroy"
)

type Watcher

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

Watcher watches for Docker container events and emits them on channels. It automatically reconnects on stream errors with exponential backoff.

func NewWatcher

func NewWatcher(docker *Client, logger *slog.Logger) *Watcher

NewWatcher creates a new Watcher that uses the given Docker client.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context) (<-chan Event, <-chan error)

Watch starts watching for container start and die events. Returns two channels: events and errors. Both are closed when ctx is cancelled.

Jump to

Keyboard shortcuts

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