dockerclient

package
v0.0.0-...-9759625 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dockerclient wraps the Docker Engine SDK for wrongtop: one call to list containers with live stats, lifecycle actions and log streaming. A missing daemon is not fatal — callers surface a notice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyLogStream

func CopyLogStream(w io.Writer, r io.Reader, tty bool) error

CopyLogStream copies a container log stream to w, demultiplexing the stdout/stderr frames the daemon prepends when the container has no TTY. It returns when the stream ends or ctx's reader is closed.

Types

type Client

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

Client talks to a local Docker daemon.

func New

func New() (*Client, error)

New connects to the daemon (DOCKER_HOST or the default socket/pipe) and verifies it answers. The returned client must be Closed.

func (*Client) Close

func (c *Client) Close() error

Close releases the connection.

func (*Client) List

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

List returns all containers; running ones carry live stats fetched concurrently (bounded), so many containers do not multiply the poll time. Stats are best-effort: zeros are fine when they fail.

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, id string, follow bool) (io.ReadCloser, bool, error)

Logs opens the container log stream (multiplexed unless the container has a TTY). Cancel ctx to stop following.

func (*Client) Restart

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

Restart restarts a container.

func (*Client) Start

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

Start starts a stopped container.

func (*Client) Stop

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

Stop stops a container, waiting up to 10s before SIGKILL.

type Container

type Container struct {
	ID     string
	Name   string
	Image  string
	State  string
	Status string
	CPU    float64 // percent of all cores
	Mem    uint64  // bytes
	MemPct float64
	NetRx  uint64 // bytes, cumulative
	NetTx  uint64
	BlkR   uint64 // bytes, cumulative
	BlkW   uint64
}

Container is wrongtop's view of one container.

type UpdateMsg

type UpdateMsg struct {
	Client     *Client
	Containers []Container
	Err        error
}

UpdateMsg carries docker polling results to the UI.

Jump to

Keyboard shortcuts

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