Documentation
¶
Overview ¶
Package docker provides Docker SDK client operations.
Package docker provides Docker SDK client operations.
Package docker provides Docker SDK client operations.
Package docker provides Docker SDK client operations.
Index ¶
- func StreamLogs(ctx context.Context, c DockerClient, containerID string, opts StreamLogsOpts) (<-chan LogLine, <-chan error)
- func WatchEvents(ctx context.Context, c DockerClient, opts WatchEventsOpts) (<-chan ContainerEvent, <-chan error)
- type ContainerEvent
- type ContainerInfo
- type DiscoverOpts
- type DockerClient
- type EventType
- type LogLine
- type StreamLogsOpts
- type WatchEventsOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamLogs ¶
func StreamLogs(ctx context.Context, c DockerClient, containerID string, opts StreamLogsOpts) (<-chan LogLine, <-chan error)
StreamLogs streams logs from a container via a channel. It demultiplexes stdout/stderr using stdcopy for non-TTY containers.
func WatchEvents ¶
func WatchEvents(ctx context.Context, c DockerClient, opts WatchEventsOpts) (<-chan ContainerEvent, <-chan error)
WatchEvents subscribes to Docker container events and streams them via a channel. It filters for start, stop, die, and restart events on containers matching the given criteria.
Types ¶
type ContainerEvent ¶
type ContainerEvent struct {
Type EventType
ContainerID string
ContainerName string
Time time.Time
}
ContainerEvent represents a Docker container lifecycle event.
type ContainerInfo ¶
ContainerInfo holds information about a discovered container.
func DiscoverContainers ¶
func DiscoverContainers(ctx context.Context, c DockerClient, opts DiscoverOpts) ([]ContainerInfo, error)
DiscoverContainers lists running containers matching the given filters.
type DiscoverOpts ¶
type DiscoverOpts struct {
// GlobPattern filters container names (empty = all)
GlobPattern string
// ComposeProject filters by Docker Compose project label (empty = ignore)
ComposeProject string
}
DiscoverOpts configures container discovery.
type DockerClient ¶
type DockerClient interface {
ContainerList(ctx context.Context, opts container.ListOptions) ([]container.Summary, error)
ContainerLogs(ctx context.Context, containerID string, opts container.LogsOptions) (io.ReadCloser, error)
ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
Events(ctx context.Context, opts events.ListOptions) (<-chan events.Message, <-chan error)
Close() error
}
DockerClient defines the interface for Docker SDK operations used by this tool. This allows for mocking in tests.
type LogLine ¶
type LogLine struct {
Timestamp time.Time
Stream string // "stdout" or "stderr"
Content string
ContainerName string
}
LogLine represents a single log entry from a container.
type StreamLogsOpts ¶
StreamLogsOpts configures log streaming.
type WatchEventsOpts ¶
type WatchEventsOpts struct {
// GlobPattern filters container names (empty = all)
GlobPattern string
// ComposeProject filters by Docker Compose project label (empty = ignore)
ComposeProject string
}
WatchEventsOpts configures event watching.