Documentation
¶
Overview ¶
Package docker implements a Source that streams container logs from the Docker daemon and dynamically attaches to new containers matching a label or name selector.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Ping(ctx context.Context) (interface{}, error) // returns types.Ping in practice; not used by our code
ContainerList(ctx context.Context, opts container.ListOptions) ([]container.Summary, error)
ContainerLogs(ctx context.Context, id string, opts container.LogsOptions) (io.ReadCloser, error)
Events(ctx context.Context, opts events.ListOptions) (<-chan events.Message, <-chan error)
Close() error
}
Client is the subset of the docker SDK we depend on. Defining it as an interface lets tests substitute a fake.
type Config ¶
type Config struct {
Name string
Container string // exact container name match
Labels map[string]string // optional label filter (AND semantics)
MaxLineLen int
}
Config holds the docker source's runtime parameters.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source streams logs from containers matching either Container (name) or Labels (label k=v filter).
func New ¶
New constructs a docker Source using a real docker client from the environment (DOCKER_HOST, /var/run/docker.sock).
func (*Source) Start ¶
Start checks the docker socket, lists currently-running matching containers, and subscribes to events for newly-started ones.
func (*Source) Unsubscribe ¶
Unsubscribe removes a subscriber and closes its channel; used during daemon.Reload to drop rules that are no longer configured.