Documentation
¶
Index ¶
- Constants
- Variables
- func CleanImageID(id string) string
- func CleanLayerCommand(cmd string) string
- func FindComposeFile(configFiles, workingDir string) string
- func FindComposeFileInAncestors(dir string) (filePath string, foundDir string)
- func FormatImageSize(size int64) string
- func FormatTimeAgo(t time.Time) string
- func IsContainerLifecycleEvent(action events.Action) bool
- func IsImageLifecycleEvent(action events.Action) bool
- func IsNetworkLifecycleEvent(action events.Action) bool
- func IsVolumeLifecycleEvent(action events.Action) bool
- func NormalizeProjectName(s string) string
- func OpenBrowser(url string) error
- func ResolveExistingFile(path string) string
- func ShortID(id string) string
- type Client
- func (c *Client) AttachShellCmd(containerID string) *exec.Cmd
- func (c *Client) Close() error
- func (c *Client) ComposeBuildCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ComposeDownCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ComposeLogsCmd(ctx context.Context, opts ComposeOpts, tail string) (*exec.Cmd, error)
- func (c *Client) ComposeRestartCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ComposeRmCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ComposeStartCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ComposeStopCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ComposeUpCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
- func (c *Client) ContainerTop(ctx context.Context, containerID string) (*container.TopResponse, error)
- func (c *Client) ExecShellCmd(containerID string) *exec.Cmd
- func (c *Client) GetImageHistory(ctx context.Context, imageID string) ([]ImageLayer, error)
- func (c *Client) Host() string
- func (c *Client) InspectContainer(ctx context.Context, containerID string) (*container.InspectResponse, error)
- func (c *Client) InspectImage(ctx context.Context, imageID string) (*image.InspectResponse, error)
- func (c *Client) InspectNetwork(ctx context.Context, networkID string) (*network.Inspect, error)
- func (c *Client) InspectVolume(ctx context.Context, name string) (*volume.Volume, error)
- func (c *Client) ListContainers(ctx context.Context) ([]ContainerInfo, error)
- func (c *Client) ListImages(ctx context.Context) ([]ImageInfo, error)
- func (c *Client) ListNetworks(ctx context.Context) ([]NetworkInfo, error)
- func (c *Client) ListVolumes(ctx context.Context) ([]VolumeInfo, error)
- func (c *Client) PauseContainer(ctx context.Context, containerID string) error
- func (c *Client) Ping() error
- func (c *Client) PruneContainers(ctx context.Context) (container.PruneReport, error)
- func (c *Client) PruneImages(ctx context.Context) (image.PruneReport, error)
- func (c *Client) PruneNetworks(ctx context.Context) (network.PruneReport, error)
- func (c *Client) PruneVolumes(ctx context.Context) (volume.PruneReport, error)
- func (c *Client) RemoveContainer(ctx context.Context, id string, opts RemoveContainerOpts) error
- func (c *Client) RemoveImage(ctx context.Context, imageID string, force bool) error
- func (c *Client) RemoveNetwork(ctx context.Context, networkID string) error
- func (c *Client) RemoveVolume(ctx context.Context, name string, force bool) error
- func (c *Client) RestartContainer(ctx context.Context, containerID string) error
- func (c *Client) StartContainer(ctx context.Context, containerID string) error
- func (c *Client) StopContainer(ctx context.Context, containerID string) error
- func (c *Client) StreamComposeLogs(ctx context.Context, opts ComposeLogOpts) <-chan string
- func (c *Client) StreamContainerLogs(ctx context.Context, id string, tail string) <-chan string
- func (c *Client) StreamContainerStats(ctx context.Context, containerID string) <-chan ContainerMetrics
- func (c *Client) StreamEvents(ctx context.Context) (<-chan events.Message, <-chan error)
- func (c *Client) UnpauseContainer(ctx context.Context, containerID string) error
- type ComposeCommandType
- type ComposeLogOpts
- type ComposeOpts
- type ComposeService
- type ContainerInfo
- type ContainerMetrics
- type ContainerService
- type ContainerState
- type EventService
- type ImageInfo
- type ImageLayer
- type ImageService
- type LocalComposeProject
- type NetworkEndpointInfo
- type NetworkInfo
- type NetworkService
- type RemoveContainerOpts
- type Service
- type VolumeContainerMount
- type VolumeInfo
- type VolumeService
Constants ¶
const ( StateCreated = container.StateCreated StateRunning = container.StateRunning StatePaused = container.StatePaused StateRestarting = container.StateRestarting StateRemoving = container.StateRemoving StateExited = container.StateExited StateDead = container.StateDead )
Variables ¶
var ( ErrComposeNotAvailable = errors.New("Docker Compose is not available on this system") // DefaultComposeFileNames contains standard filenames for Docker Compose definitions in order of precedence. DefaultComposeFileNames = []string{ "compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml", } )
var ErrMustStopContainer = errors.New("container must be stopped before removal")
Functions ¶
func CleanImageID ¶
func CleanLayerCommand ¶
CleanLayerCommand returns a single-line, Dockerfile-like instruction from a history CreatedBy string.
func FindComposeFile ¶ added in v0.4.0
FindComposeFile attempts to locate an existing compose file from comma-separated configFiles or workingDir.
func FindComposeFileInAncestors ¶ added in v0.4.0
FindComposeFileInAncestors starts at dir and walks up parent directories until a compose file is found. It returns the path to the compose file and the directory containing it. If dir is empty, it uses the current working directory.
func FormatImageSize ¶
func FormatTimeAgo ¶
FormatTimeAgo formats a time into a relative "X ago" string.
func IsContainerLifecycleEvent ¶
IsContainerLifecycleEvent returns true if the event represents an actual state/lifecycle change of a container.
func IsImageLifecycleEvent ¶
IsImageLifecycleEvent returns true if the event represents an addition, removal, or tag change of an image.
func IsNetworkLifecycleEvent ¶
IsNetworkLifecycleEvent returns true if the event represents a network lifecycle modification.
func IsVolumeLifecycleEvent ¶
IsVolumeLifecycleEvent returns true if the event represents a volume lifecycle modification.
func NormalizeProjectName ¶ added in v0.4.0
NormalizeProjectName converts a directory or project name to a valid compose project name by lowercasing and stripping characters that are not [a-z0-9_-].
func OpenBrowser ¶ added in v0.3.1
OpenBrowser opens the given URL in the user's default web browser.
func ResolveExistingFile ¶ added in v0.4.0
ResolveExistingFile checks if a path exists, handling Windows/WSL2 path conversions if applicable.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient initializes a Docker API client using intelligent multi-tier host resolution.
The optional hosts parameter allows callers to pass an explicit endpoint (e.g. from CLI flag -H/--host or config file). If multiple hosts are provided, only the first non-empty one is used.
Host resolution precedence:
- Explicit host argument passed to NewClient (if non-empty)
- DOCKER_HOST environment variable (if set and non-empty)
- Active Docker context from ~/.docker/config.json or $DOCKER_CONTEXT
- Probed local daemon sockets (macOS user sockets, Windows WSL2 named pipe, Linux rootless)
- Standard Moby default socket (/var/run/docker.sock)
Upon successful client initialization, NewClient immediately executes a Ping with a 5-second timeout to negotiate the API version and ensure daemon reachability before returning.
func (*Client) AttachShellCmd ¶ added in v0.3.1
func (*Client) ComposeBuildCmd ¶ added in v0.4.0
ComposeBuildCmd returns a command to build images and start services in detached mode.
func (*Client) ComposeDownCmd ¶ added in v0.4.0
ComposeDownCmd returns a command to stop and remove containers, networks created by compose.
func (*Client) ComposeLogsCmd ¶ added in v0.4.0
func (c *Client) ComposeLogsCmd(ctx context.Context, opts ComposeOpts, tail string) (*exec.Cmd, error)
ComposeLogsCmd returns a command to stream compose logs.
func (*Client) ComposeRestartCmd ¶ added in v0.4.0
ComposeRestartCmd returns a command to restart compose services.
func (*Client) ComposeRmCmd ¶ added in v0.4.0
ComposeRmCmd returns a command to remove stopped service containers.
func (*Client) ComposeStartCmd ¶ added in v0.4.0
ComposeStartCmd returns a command to start stopped compose services.
func (*Client) ComposeStopCmd ¶ added in v0.4.0
ComposeStopCmd returns a command to stop compose services.
func (*Client) ComposeUpCmd ¶ added in v0.4.0
ComposeUpCmd returns a command to start services in detached mode.
func (*Client) ContainerTop ¶
func (*Client) GetImageHistory ¶
GetImageHistory fetches layers history for an image.
func (*Client) InspectContainer ¶
func (*Client) InspectImage ¶
InspectImage fetches full inspection metadata for an image.
func (*Client) InspectNetwork ¶
InspectNetwork fetches full inspection metadata for a network
func (*Client) InspectVolume ¶
InspectVolume retrieves deep inspect data for a volume
func (*Client) ListContainers ¶
func (c *Client) ListContainers(ctx context.Context) ([]ContainerInfo, error)
Docker container cmd
func (*Client) ListImages ¶
ListImages retrieves images and annotates them with container usage and status.
func (*Client) ListNetworks ¶
func (c *Client) ListNetworks(ctx context.Context) ([]NetworkInfo, error)
ListNetworks retrieves all Docker networks with detailed endpoint metadata
func (*Client) ListVolumes ¶
func (c *Client) ListVolumes(ctx context.Context) ([]VolumeInfo, error)
ListVolumes retrieves all docker volumes and cross-references them with active/stopped containers
func (*Client) PauseContainer ¶
func (*Client) PruneContainers ¶
func (*Client) PruneImages ¶
PruneImages removes dangling images.
func (*Client) PruneNetworks ¶
PruneNetworks removes unused networks
func (*Client) PruneVolumes ¶
PruneVolumes removes all unused local volumes
func (*Client) RemoveContainer ¶
func (*Client) RemoveImage ¶
RemoveImage deletes an image by ID or tag.
func (*Client) RemoveNetwork ¶
RemoveNetwork deletes a network by ID or name
func (*Client) RemoveVolume ¶
RemoveVolume deletes a volume by name
func (*Client) RestartContainer ¶
func (*Client) StartContainer ¶
func (*Client) StopContainer ¶
func (*Client) StreamComposeLogs ¶
func (c *Client) StreamComposeLogs(ctx context.Context, opts ComposeLogOpts) <-chan string
func (*Client) StreamContainerLogs ¶
func (*Client) StreamContainerStats ¶
func (c *Client) StreamContainerStats(ctx context.Context, containerID string) <-chan ContainerMetrics
func (*Client) StreamEvents ¶
type ComposeCommandType ¶ added in v0.4.0
type ComposeCommandType string
ComposeCommandType represents the variant of Docker Compose available on the host.
const ( ComposeV2 ComposeCommandType = "docker compose" ComposeV1 ComposeCommandType = "docker-compose" ComposeNone ComposeCommandType = "none" )
type ComposeLogOpts ¶
type ComposeOpts ¶ added in v0.4.0
ComposeOpts specifies parameters to target a Docker Compose project or service.
type ComposeService ¶ added in v0.4.0
type ComposeService interface {
ComposeUpCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
ComposeBuildCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
ComposeDownCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
ComposeRestartCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
ComposeStopCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
ComposeStartCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
ComposeRmCmd(ctx context.Context, opts ComposeOpts) (*exec.Cmd, error)
StreamComposeLogs(ctx context.Context, opts ComposeLogOpts) <-chan string
}
ComposeService defines lifecycle commands for Docker Compose projects and services.
type ContainerInfo ¶
type ContainerInfo struct {
ID string
Name string
Image string
Status string
State container.ContainerState
Ports string
// Doker Compose labels
IsCompose bool
ProjectName string
Service string
ContainerNumber int
OneOff bool
ConfigFiles string
WorkingDir string
Details *container.InspectResponse
}
func (*ContainerInfo) HasDetailsLoaded ¶
func (c *ContainerInfo) HasDetailsLoaded() bool
func (*ContainerInfo) ShortID ¶
func (c *ContainerInfo) ShortID() string
func (ContainerInfo) WebURL ¶ added in v0.3.1
func (c ContainerInfo) WebURL() (string, bool)
type ContainerMetrics ¶
type ContainerMetrics struct {
CPUPercent float64
MemUsage float64
MemLimit float64
HasMemLimit bool
NetworkRx float64
NetworkTx float64
BlockRead uint64
BlockWrite uint64
}
func CalculateStats ¶
func CalculateStats(v *container.StatsResponse) ContainerMetrics
type ContainerService ¶
type ContainerService interface {
ListContainers(ctx context.Context) ([]ContainerInfo, error)
InspectContainer(ctx context.Context, containerID string) (*container.InspectResponse, error)
ContainerTop(ctx context.Context, containerID string) (*container.TopResponse, error)
StartContainer(ctx context.Context, containerID string) error
StopContainer(ctx context.Context, containerID string) error
RestartContainer(ctx context.Context, containerID string) error
PauseContainer(ctx context.Context, containerID string) error
UnpauseContainer(ctx context.Context, containerID string) error
RemoveContainer(ctx context.Context, id string, opts RemoveContainerOpts) error
PruneContainers(ctx context.Context) (container.PruneReport, error)
ExecShellCmd(containerID string) *exec.Cmd
AttachShellCmd(containerID string) *exec.Cmd
StreamContainerLogs(ctx context.Context, containerID string, tail string) <-chan string
StreamContainerStats(ctx context.Context, id string) <-chan ContainerMetrics
ComposeService
}
ContainerService defines the narrow interface required by Container components.
type ContainerState ¶ added in v0.2.0
type ContainerState = container.ContainerState
type EventService ¶
type EventService interface {
StreamEvents(ctx context.Context) (<-chan events.Message, <-chan error)
}
EventService defines daemon lifecycle streaming.
type ImageLayer ¶
type ImageService ¶
type ImageService interface {
ListImages(ctx context.Context) ([]ImageInfo, error)
InspectImage(ctx context.Context, id string) (*image.InspectResponse, error)
GetImageHistory(ctx context.Context, id string) ([]ImageLayer, error)
RemoveImage(ctx context.Context, id string, force bool) error
PruneImages(ctx context.Context) (image.PruneReport, error)
}
ImageService defines the narrow interface required by Image components.
type LocalComposeProject ¶ added in v0.4.0
type LocalComposeProject struct {
ProjectName string
WorkingDir string
ConfigFile string
Services []string
}
LocalComposeProject holds metadata discovered from a local compose file.
func DetectLocalCompose ¶ added in v0.4.0
func DetectLocalCompose(dir string) (*LocalComposeProject, error)
DetectLocalCompose scans the given directory and its parent directories for compose files and parses service names. If dir is empty, it uses the current working directory.
type NetworkEndpointInfo ¶
type NetworkEndpointInfo struct {
ContainerID string
Name string
IP string
MacAddress string
Ports string
}
NetworkEndpointInfo represents a container connected to a network
type NetworkInfo ¶
type NetworkService ¶
type NetworkService interface {
ListNetworks(ctx context.Context) ([]NetworkInfo, error)
InspectNetwork(ctx context.Context, id string) (*network.Inspect, error)
RemoveNetwork(ctx context.Context, id string) error
PruneNetworks(ctx context.Context) (network.PruneReport, error)
}
NetworkService defines the narrow interface required by Network components.
type RemoveContainerOpts ¶
type Service ¶
type Service interface {
ContainerService
ImageService
VolumeService
NetworkService
EventService
Host() string
Close() error
Ping() error
}
Service is an idiomatic composite interface combining all domain sub-services. Used by the root AppModel to orchestrate all tabs and engine events.
type VolumeContainerMount ¶
type VolumeContainerMount struct {
ContainerID string
ContainerName string
State container.ContainerState
Destination string
Mode string
RW bool
}
VolumeContainerMount describes a container currently mounting a volume
type VolumeInfo ¶
type VolumeInfo struct {
volume.Volume
InUse bool
RefCnt int
Containers []VolumeContainerMount
}
VolumeInfo encapsulates metadata and live container usage for a Docker volume
type VolumeService ¶
type VolumeService interface {
ListVolumes(ctx context.Context) ([]VolumeInfo, error)
InspectVolume(ctx context.Context, name string) (*volume.Volume, error)
RemoveVolume(ctx context.Context, name string, force bool) error
PruneVolumes(ctx context.Context) (volume.PruneReport, error)
}
VolumeService defines the narrow interface required by Volume components.