Documentation
¶
Overview ¶
Package docker provides a thin client wrapper around the Docker Engine API.
Index ¶
- func CollectContainerStats(client statsFetcher, ids []string, batchEvery time.Duration, ...)
- func StatsBatchInterval() time.Duration
- func StripDockerLogHeaderForUI(line string) string
- type Client
- func (c *Client) Close() error
- func (c *Client) GetAllContainerStats(ids []string) map[string]*ContainerResourceStats
- func (c *Client) GetContainerDiff(id string) ([]DiffEntry, error)
- func (c *Client) GetContainerLogRecords(id string, lines int) ([]LogRecord, error)
- func (c *Client) GetContainerLogRecordsStream(ctx context.Context, id string, tail int) (io.ReadCloser, error)
- func (c *Client) GetContainerLogs(id string, lines int) (string, error)
- func (c *Client) GetContainerLogsStream(ctx context.Context, id string) (io.ReadCloser, error)
- func (c *Client) GetContainerStats(id string) (*ContainerResourceStats, error)
- func (c *Client) GetContainerTop(id string) (ContainerTop, error)
- func (c *Client) GetDockerOverview() (*DockerOverview, error)
- func (c *Client) InspectContainer(id string) (*ContainerInfo, error)
- func (c *Client) KillContainer(id string, signal string) error
- func (c *Client) ListContainers() ([]ContainerInfo, error)
- func (c *Client) ListImages() ([]ImageInfo, error)
- func (c *Client) ListNetworks() ([]NetworkResource, error)
- func (c *Client) ListVolumes() ([]VolumeInfo, error)
- func (c *Client) PauseContainer(id string) error
- func (c *Client) PruneDanglingImages() (ImagePruneResult, error)
- func (c *Client) PruneVolumes() ([]string, error)
- func (c *Client) PullImage(ref string) error
- func (c *Client) PullImageWithProgress(ref string, onProgress func(string)) error
- func (c *Client) RemoveContainer(id string, force bool) error
- func (c *Client) RemoveImage(id string, force bool) error
- func (c *Client) RemoveNetwork(id string) error
- func (c *Client) RemoveVolume(name string) error
- func (c *Client) RestartContainer(id string) error
- func (c *Client) StartContainer(id string) error
- func (c *Client) StartContainerExecShell(ctx context.Context, id, shell string) (io.ReadWriteCloser, error)
- func (c *Client) StopContainer(id string) error
- func (c *Client) StreamEvents(ctx context.Context) <-chan DockerEvent
- func (c *Client) SystemPrune() (SystemPruneResult, error)
- func (c *Client) UnpauseContainer(id string) error
- type ClientAPI
- type ContainerInfo
- type ContainerResourceStats
- type ContainerTop
- type DiffEntry
- type DockerEvent
- type DockerOverview
- type FakeClient
- func (f *FakeClient) Close() error
- func (f *FakeClient) GetAllContainerStats(ids []string) map[string]*ContainerResourceStats
- func (f *FakeClient) GetContainerDiff(id string) ([]DiffEntry, error)
- func (f *FakeClient) GetContainerLogRecords(id string, lines int) ([]LogRecord, error)
- func (f *FakeClient) GetContainerLogRecordsStream(ctx context.Context, id string, tail int) (io.ReadCloser, error)
- func (f *FakeClient) GetContainerLogs(id string, lines int) (string, error)
- func (f *FakeClient) GetContainerLogsStream(ctx context.Context, id string) (io.ReadCloser, error)
- func (f *FakeClient) GetContainerStats(id string) (*ContainerResourceStats, error)
- func (f *FakeClient) GetContainerTop(id string) (ContainerTop, error)
- func (f *FakeClient) GetDockerOverview() (*DockerOverview, error)
- func (f *FakeClient) InspectContainer(id string) (*ContainerInfo, error)
- func (f *FakeClient) KillContainer(id, signal string) error
- func (f *FakeClient) ListContainers() ([]ContainerInfo, error)
- func (f *FakeClient) ListImages() ([]ImageInfo, error)
- func (f *FakeClient) ListNetworks() ([]NetworkResource, error)
- func (f *FakeClient) ListVolumes() ([]VolumeInfo, error)
- func (f *FakeClient) PauseContainer(id string) error
- func (f *FakeClient) PruneDanglingImages() (ImagePruneResult, error)
- func (f *FakeClient) PruneVolumes() ([]string, error)
- func (f *FakeClient) PullImage(ref string) error
- func (f *FakeClient) PullImageWithProgress(ref string, onProgress func(string)) error
- func (f *FakeClient) RemoveContainer(id string, force bool) error
- func (f *FakeClient) RemoveImage(id string, force bool) error
- func (f *FakeClient) RemoveNetwork(id string) error
- func (f *FakeClient) RemoveVolume(name string) error
- func (f *FakeClient) RestartContainer(id string) error
- func (f *FakeClient) StartContainer(id string) error
- func (f *FakeClient) StartContainerExecShell(ctx context.Context, id, shell string) (io.ReadWriteCloser, error)
- func (f *FakeClient) StopContainer(id string) error
- func (f *FakeClient) StreamEvents(ctx context.Context) <-chan DockerEvent
- func (f *FakeClient) SystemPrune() (SystemPruneResult, error)
- func (f *FakeClient) UnpauseContainer(id string) error
- type ImageInfo
- type ImagePruneResult
- type LogRecord
- type MountInfo
- type NetworkInfo
- type NetworkResource
- type PortBinding
- type StatsBatch
- type SystemLoad
- type SystemMemory
- type SystemPruneResult
- type VolumeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectContainerStats ¶ added in v0.2.0
func CollectContainerStats(client statsFetcher, ids []string, batchEvery time.Duration, deliver func(StatsBatch))
CollectContainerStats fetches stats for ids with bounded concurrency and delivers partial maps on batchEvery until all requests finish.
func StatsBatchInterval ¶ added in v0.2.0
StatsBatchInterval is how often partial stats maps are delivered.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetAllContainerStats ¶
func (c *Client) GetAllContainerStats(ids []string) map[string]*ContainerResourceStats
func (*Client) GetContainerLogRecords ¶
func (*Client) GetContainerLogRecordsStream ¶
func (*Client) GetContainerLogs ¶
func (*Client) GetContainerLogsStream ¶
func (*Client) GetContainerStats ¶
func (c *Client) GetContainerStats(id string) (*ContainerResourceStats, error)
func (*Client) GetContainerTop ¶
func (c *Client) GetContainerTop(id string) (ContainerTop, error)
func (*Client) GetDockerOverview ¶
func (c *Client) GetDockerOverview() (*DockerOverview, error)
func (*Client) InspectContainer ¶
func (c *Client) InspectContainer(id string) (*ContainerInfo, error)
func (*Client) ListContainers ¶
func (c *Client) ListContainers() ([]ContainerInfo, error)
func (*Client) ListImages ¶
func (*Client) ListNetworks ¶
func (c *Client) ListNetworks() ([]NetworkResource, error)
func (*Client) ListVolumes ¶
func (c *Client) ListVolumes() ([]VolumeInfo, error)
func (*Client) PauseContainer ¶
func (*Client) PruneDanglingImages ¶
func (c *Client) PruneDanglingImages() (ImagePruneResult, error)
func (*Client) PruneVolumes ¶
func (*Client) PullImageWithProgress ¶
func (*Client) RemoveNetwork ¶
func (*Client) RemoveVolume ¶
func (*Client) RestartContainer ¶
func (*Client) StartContainer ¶
func (*Client) StartContainerExecShell ¶
func (*Client) StopContainer ¶
func (*Client) StreamEvents ¶
func (c *Client) StreamEvents(ctx context.Context) <-chan DockerEvent
StreamEvents returns a channel of DockerEvents and a cancel func. Close the returned cancel to stop the stream.
func (*Client) SystemPrune ¶
func (c *Client) SystemPrune() (SystemPruneResult, error)
func (*Client) UnpauseContainer ¶
type ClientAPI ¶
type ClientAPI interface {
// Container operations
ListContainers() ([]ContainerInfo, error)
InspectContainer(id string) (*ContainerInfo, error)
StartContainer(id string) error
StopContainer(id string) error
RestartContainer(id string) error
PauseContainer(id string) error
UnpauseContainer(id string) error
KillContainer(id string, signal string) error
RemoveContainer(id string, force bool) error
GetContainerDiff(id string) ([]DiffEntry, error)
GetContainerTop(id string) (ContainerTop, error)
GetContainerLogs(id string, lines int) (string, error)
GetContainerLogRecords(id string, lines int) ([]LogRecord, error)
GetContainerLogsStream(ctx context.Context, id string) (io.ReadCloser, error)
GetContainerLogRecordsStream(ctx context.Context, id string, tail int) (io.ReadCloser, error)
StartContainerExecShell(ctx context.Context, id, shell string) (io.ReadWriteCloser, error)
// Stats
GetContainerStats(id string) (*ContainerResourceStats, error)
GetAllContainerStats(ids []string) map[string]*ContainerResourceStats
// Images
ListImages() ([]ImageInfo, error)
RemoveImage(id string, force bool) error
PullImage(ref string) error
PullImageWithProgress(ref string, onProgress func(string)) error
PruneDanglingImages() (ImagePruneResult, error)
// Networks
ListNetworks() ([]NetworkResource, error)
RemoveNetwork(id string) error
// Volumes
ListVolumes() ([]VolumeInfo, error)
RemoveVolume(name string) error
PruneVolumes() ([]string, error)
SystemPrune() (SystemPruneResult, error)
// Events
StreamEvents(ctx context.Context) <-chan DockerEvent
// System info
GetDockerOverview() (*DockerOverview, error)
// Lifecycle
Close() error
}
ClientAPI defines the Docker operations used by the UI. A concrete *Client satisfies this interface; tests can use a mock.
type ContainerInfo ¶
type ContainerInfo struct {
ID string
Name string
Image string
Status string
State string
Health string
Created time.Time
Ports []PortBinding
Mounts []MountInfo
Network map[string]NetworkInfo
Env []string
Labels map[string]string
Command string
Platform string
RestartCount int
StartedAt time.Time
CPUQuota int64
CPUPeriod int64
MemoryLimit int64
RestartPolicy string
}
type ContainerResourceStats ¶
type ContainerTop ¶
type DockerEvent ¶
type DockerOverview ¶
type FakeClient ¶
type FakeClient struct {
Containers []ContainerInfo
Volumes []VolumeInfo
Networks []NetworkResource
Images []ImageInfo
}
FakeClient is a minimal ClientAPI stub for tests.
func (*FakeClient) Close ¶
func (f *FakeClient) Close() error
func (*FakeClient) GetAllContainerStats ¶
func (f *FakeClient) GetAllContainerStats(ids []string) map[string]*ContainerResourceStats
func (*FakeClient) GetContainerDiff ¶
func (f *FakeClient) GetContainerDiff(id string) ([]DiffEntry, error)
func (*FakeClient) GetContainerLogRecords ¶
func (f *FakeClient) GetContainerLogRecords(id string, lines int) ([]LogRecord, error)
func (*FakeClient) GetContainerLogRecordsStream ¶
func (f *FakeClient) GetContainerLogRecordsStream(ctx context.Context, id string, tail int) (io.ReadCloser, error)
func (*FakeClient) GetContainerLogs ¶
func (f *FakeClient) GetContainerLogs(id string, lines int) (string, error)
func (*FakeClient) GetContainerLogsStream ¶
func (f *FakeClient) GetContainerLogsStream(ctx context.Context, id string) (io.ReadCloser, error)
func (*FakeClient) GetContainerStats ¶
func (f *FakeClient) GetContainerStats(id string) (*ContainerResourceStats, error)
func (*FakeClient) GetContainerTop ¶
func (f *FakeClient) GetContainerTop(id string) (ContainerTop, error)
func (*FakeClient) GetDockerOverview ¶
func (f *FakeClient) GetDockerOverview() (*DockerOverview, error)
func (*FakeClient) InspectContainer ¶
func (f *FakeClient) InspectContainer(id string) (*ContainerInfo, error)
func (*FakeClient) KillContainer ¶
func (f *FakeClient) KillContainer(id, signal string) error
func (*FakeClient) ListContainers ¶
func (f *FakeClient) ListContainers() ([]ContainerInfo, error)
func (*FakeClient) ListImages ¶
func (f *FakeClient) ListImages() ([]ImageInfo, error)
func (*FakeClient) ListNetworks ¶
func (f *FakeClient) ListNetworks() ([]NetworkResource, error)
func (*FakeClient) ListVolumes ¶
func (f *FakeClient) ListVolumes() ([]VolumeInfo, error)
func (*FakeClient) PauseContainer ¶
func (f *FakeClient) PauseContainer(id string) error
func (*FakeClient) PruneDanglingImages ¶
func (f *FakeClient) PruneDanglingImages() (ImagePruneResult, error)
func (*FakeClient) PruneVolumes ¶
func (f *FakeClient) PruneVolumes() ([]string, error)
func (*FakeClient) PullImage ¶
func (f *FakeClient) PullImage(ref string) error
func (*FakeClient) PullImageWithProgress ¶
func (f *FakeClient) PullImageWithProgress(ref string, onProgress func(string)) error
func (*FakeClient) RemoveContainer ¶
func (f *FakeClient) RemoveContainer(id string, force bool) error
func (*FakeClient) RemoveImage ¶
func (f *FakeClient) RemoveImage(id string, force bool) error
func (*FakeClient) RemoveNetwork ¶
func (f *FakeClient) RemoveNetwork(id string) error
func (*FakeClient) RemoveVolume ¶
func (f *FakeClient) RemoveVolume(name string) error
func (*FakeClient) RestartContainer ¶
func (f *FakeClient) RestartContainer(id string) error
func (*FakeClient) StartContainer ¶
func (f *FakeClient) StartContainer(id string) error
func (*FakeClient) StartContainerExecShell ¶
func (f *FakeClient) StartContainerExecShell(ctx context.Context, id, shell string) (io.ReadWriteCloser, error)
func (*FakeClient) StopContainer ¶
func (f *FakeClient) StopContainer(id string) error
func (*FakeClient) StreamEvents ¶
func (f *FakeClient) StreamEvents(ctx context.Context) <-chan DockerEvent
func (*FakeClient) SystemPrune ¶
func (f *FakeClient) SystemPrune() (SystemPruneResult, error)
func (*FakeClient) UnpauseContainer ¶
func (f *FakeClient) UnpauseContainer(id string) error
type ImageInfo ¶
func (ImageInfo) DisplayTag ¶
type ImagePruneResult ¶
type LogRecord ¶
func ParseDockerLogRecord ¶
type NetworkInfo ¶
type NetworkResource ¶
type PortBinding ¶
type StatsBatch ¶ added in v0.2.0
type StatsBatch struct {
Stats map[string]*ContainerResourceStats
Done bool
}
StatsBatch is one partial result from CollectContainerStats.
type SystemLoad ¶
SystemLoad holds host load averages.
func GetSystemLoad ¶
func GetSystemLoad() SystemLoad
type SystemMemory ¶
SystemMemory holds host memory statistics.
func GetSystemMemory ¶
func GetSystemMemory() SystemMemory
type SystemPruneResult ¶
type VolumeInfo ¶
type VolumeInfo struct {
Name string
Driver string
Mountpoint string
Labels map[string]string
Scope string
CreatedAt time.Time
}
func (VolumeInfo) DisplayName ¶
func (v VolumeInfo) DisplayName() string