docker

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 13 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 official Docker SDK client.

func NewClient

func NewClient() (*Client, error)

NewClient creates a Client connected to the local Docker daemon via DOCKER_HOST / Unix socket.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying Docker client.

func (*Client) FetchLogLines added in v0.2.0

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

FetchLogLines returns the last tail lines of stdout+stderr as a slice (oldest first).

func (*Client) FetchStatesByID added in v0.2.0

func (c *Client) FetchStatesByID(ctx context.Context, ids []string) (map[string]ContainerState, error)

FetchStatesByID returns observed states keyed by container ID. IDs not found in the current list are omitted; callers keep the last known state.

func (*Client) ListAll added in v0.2.0

func (c *Client) ListAll(ctx context.Context) ([]ContainerInfo, error)

ListAll returns every container on the daemon (running and stopped).

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, containerID string, lines int) (string, error)

Logs returns the last n lines of stdout+stderr for containerID.

func (*Client) StartLogStreamCh added in v0.2.0

func (c *Client) StartLogStreamCh(ctx context.Context, containerID string, tail int) <-chan LogLineMsg

StartLogStreamCh launches a goroutine that tails container logs with Follow enabled. The channel closes when ctx is cancelled, the stream ends, or an error occurs.

func (*Client) StartPollCh added in v0.2.0

func (c *Client) StartPollCh(ctx context.Context) <-chan PollMsg

StartPollCh launches a background goroutine that polls Docker every 500 ms and sends a PollMsg on the returned channel. The goroutine exits when ctx is cancelled and the channel is then closed.

type ContainerInfo added in v0.2.0

type ContainerInfo struct {
	ID       string
	Names    []string
	Image    string
	Labels   map[string]string
	State    ContainerState
	ExitCode *int     // parsed from Status "Exited (N) ..."; nil while running
	Status   string   // raw human-readable Docker status string
	Ports    []string // formatted "8080:80/tcp" (published) or "80/tcp" (exposed only)
	Created  int64    // unix seconds, from container.Summary.Created
}

ContainerInfo holds discovered container metadata from a single list call.

type ContainerState

type ContainerState int

ContainerState represents the observed lifecycle state of a container.

const (
	StatePending   ContainerState = iota // waiting on a dependency; not yet started
	StateStarting                        // container exists, health check running
	StateHealthy                         // running and health check passing (or no healthcheck)
	StateUnhealthy                       // health check explicitly failing
	StateExited                          // stopped with non-zero exit code
)

The set of observable container lifecycle states, ordered from not-yet-started to terminal.

func (ContainerState) String

func (s ContainerState) String() string

type LogLineMsg added in v0.2.0

type LogLineMsg struct {
	Line string
	Err  error
}

LogLineMsg carries one line from a streaming log follow, or anaconda terminal error.

type PollMsg added in v0.2.0

type PollMsg struct {
	Containers []ContainerInfo
}

PollMsg is a Bubble Tea message emitted each poll cycle with full container metadata.

Jump to

Keyboard shortcuts

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