Documentation
¶
Index ¶
- func GenerateRandomString(length int) string
- func StatsFormatter(writer io.Writer) *formater
- type Client
- func (c *Client) BuildImage(ctx context.Context, imageConfig *image.ImageConfig) error
- func (c *Client) ConnectContainerToNetwork(ctx context.Context, networkConfig *network.NetworkConfig, ...) error
- func (c *Client) ContainerWait(ctx context.Context, containerConfig *container.ContainerConfig) (<-chan containerType.WaitResponse, <-chan error)
- func (c *Client) CreateContainer(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) CreateNetwork(ctx context.Context, networkConfig *network.NetworkConfig) error
- func (c *Client) CreateVolume(ctx context.Context, volumeConfig *volume.VolumeConfig) error
- func (c *Client) DisconnectContainerFromNetwork(ctx context.Context, networkConfig *network.NetworkConfig, ...) error
- func (c *Client) GetContainerLogs(ctx context.Context, containerConfig *container.ContainerConfig) (io.ReadCloser, error)
- func (c *Client) GetContainerStats(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) LoadImage(ctx context.Context, inputFile string) error
- func (c *Client) PauseContainer(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) PruneVolumes(ctx context.Context, filterMap map[string][]string) (uint64, error)
- func (c *Client) PullImage(ctx context.Context, imageConfig *image.ImageConfig) error
- func (c *Client) PushImage(ctx context.Context, imageConfig *image.ImageConfig) error
- func (c *Client) RemoveContainer(ctx context.Context, containerConfig *container.ContainerConfig, force bool) error
- func (c *Client) RemoveImage(ctx context.Context, imageConfig *image.ImageConfig, force bool) error
- func (c *Client) RemoveNetwork(ctx context.Context, networkConfig *network.NetworkConfig) error
- func (c *Client) RemoveVolume(ctx context.Context, volumeConfig *volume.VolumeConfig) error
- func (c *Client) RestartContainer(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) SaveImage(ctx context.Context, imageConfig *image.ImageConfig, outputFile string) error
- func (c *Client) SetImageResponeWriter(dst io.Writer)
- func (c *Client) SetLogResponseWriter(dst io.Writer)
- func (c *Client) SetStatsResponeWriter(dst io.Writer)
- func (c *Client) StartContainer(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) StopContainer(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) String() string
- func (c *Client) TagImage(ctx context.Context, imageConfig *image.ImageConfig, newTag string) error
- func (c *Client) UnpauseContainer(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) Unwrap() client.APIClient
- type ContainerStats
- type FormatedContainerStats
- type ImageProgress
- type LogCopier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomString ¶
func StatsFormatter ¶
Formats the incoming stats and passes it to the supplied writer
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) BuildImage ¶
func (*Client) ConnectContainerToNetwork ¶
func (c *Client) ConnectContainerToNetwork(ctx context.Context, networkConfig *network.NetworkConfig, containerConfig *container.ContainerConfig) error
func (*Client) ContainerWait ¶
func (c *Client) ContainerWait(ctx context.Context, containerConfig *container.ContainerConfig) (<-chan containerType.WaitResponse, <-chan error)
ContainerWait waits for a container to finish and returns a channel for status and errors
func (*Client) CreateContainer ¶
func (*Client) CreateNetwork ¶
func (*Client) CreateVolume ¶
func (*Client) DisconnectContainerFromNetwork ¶
func (c *Client) DisconnectContainerFromNetwork(ctx context.Context, networkConfig *network.NetworkConfig, containerConfig *container.ContainerConfig, force bool) error
func (*Client) GetContainerLogs ¶
func (c *Client) GetContainerLogs(ctx context.Context, containerConfig *container.ContainerConfig) (io.ReadCloser, error)
GetContainerLogs returns a ReadCloser for container logs. If a custom log writer is configured, logs will also be written to it asynchronously. Caller is responsible for closing the returned reader.
func (*Client) GetContainerStats ¶
func (c *Client) GetContainerStats(ctx context.Context, containerConfig *container.ContainerConfig) error
GetContainerStats gets stats and is synchronus This is a blocking call and will return when the container is stopped or the context is cancelled
func (*Client) PauseContainer ¶
func (*Client) PruneVolumes ¶
func (*Client) RemoveContainer ¶
func (*Client) RemoveImage ¶
func (*Client) RemoveNetwork ¶
func (*Client) RemoveVolume ¶
func (*Client) RestartContainer ¶
func (*Client) SetImageResponeWriter ¶
SetImageResponeWriter sets the image response writer for Docker's API. If this is not set, the client wrapper will default to stdout.
func (*Client) SetLogResponseWriter ¶
This sets the log output response writer for Docker's API. If this is not set, the client wrapper will default to stdout.
func (*Client) SetStatsResponeWriter ¶
This sets the stats response writer for Docker's API. If this is not set, the client wrapper will default to StatsFormatter.
func (*Client) StartContainer ¶
func (*Client) StopContainer ¶
func (*Client) UnpauseContainer ¶
type ContainerStats ¶
type ContainerStats struct {
Name string `json:"name"`
ID string `json:"id"`
Read string `json:"read"`
Preread string `json:"preread"`
PidsStats struct {
Current int64 `json:"current"`
Limit json.Number `json:"limit"`
} `json:"pidsStats"`
BlkioStats struct {
IoServiceBytesRecursive []any `json:"ioServiceBytesRecursive"`
IoServicedRecursive []any `json:"ioServicedRecursive"`
IoQueueRecursive []any `json:"ioQueueRecursive"`
IoServiceTimeRecursive []any `json:"ioServiceTimeRecursive"`
IoWaitTimeRecursive []any `json:"ioWaitTimeRecursive"`
IoMergedRecursive []any `json:"ioMergedRecursive"`
IoTimeRecursive []any `json:"ioTimeRecursive"`
SectorsRecursive []any `json:"sectorsRecursive"`
} `json:"blkioStats"`
NumProcs int64 `json:"numProcs"`
StorageStats struct{} `json:"storageStats"`
CpuStats struct {
CpuUsage struct {
TotalUsage int64 `json:"totalUsage"`
UsageInKernelMode int64 `json:"usageInKernelmode"`
UsageInUserMode int64 `json:"usageInUsermode"`
} `json:"cpuUsage"`
SystemCPUUsage int64 `json:"systemCpuUsage"`
OnlineCPUs int64 `json:"onlineCpus"`
ThrottlingData struct {
Periods int64 `json:"periods"`
ThrottledPeriods int64 `json:"throttledPeriods"`
ThrottledTime int64 `json:"throttledTime"`
} `json:"throttlingData"`
} `json:"cpuStats"`
PreCPUStats struct {
CpuUsage struct {
TotalUsage int64 `json:"totalUsage"`
UsageInKernelMode int64 `json:"usageInKernelmode"`
UsageInUserMode int64 `json:"usageInUsermode"`
} `json:"cpuUsage"`
SystemCPUUsage int64 `json:"systemCpuUsage"`
OnlineCPUs int64 `json:"onlineCpus"`
ThrottlingData struct {
Periods int64 `json:"periods"`
ThrottledPeriods int64 `json:"throttledPeriods"`
ThrottledTime int64 `json:"throttledTime"`
} `json:"throttlingData"`
} `json:"precpuStats"`
MemoryStats struct {
Usage int64 `json:"usage"`
Stats struct {
ActiveAnon int64 `json:"activeAnon"`
ActiveFile int64 `json:"activeFile"`
Anon int64 `json:"anon"`
AnonTHP int64 `json:"anonTHP"`
File int64 `json:"file"`
FileDirty int64 `json:"fileDirty"`
FileMapped int64 `json:"fileMapped"`
FileWriteBack int64 `json:"fileWriteback"`
InactiveAnon int64 `json:"inactiveAnon"`
InactiveFile int64 `json:"inactiveFile"`
KernelStack int64 `json:"kernelStack"`
PgActivate int64 `json:"pgActivate"`
PgDeactivate int64 `json:"pgDeactivate"`
PgFault int64 `json:"pgFault"`
PgLazyFree int64 `json:"pgLazyFree"`
PgLazyFreed int64 `json:"pgLazyFreed"`
PgMajFault int64 `json:"pgMajFault"`
PgRefill int64 `json:"pgRefill"`
PgScan int64 `json:"pgScan"`
PgSteal int64 `json:"pgSteal"`
Shmem int64 `json:"shmem"`
Slab int64 `json:"slab"`
SlabReclaimable int64 `json:"slabReclaimable"`
SlabUnreclaimable int64 `json:"slabUnreclaimable"`
Sock int64 `json:"sock"`
ThpCollapseAlloc int64 `json:"thpCollapseAlloc"`
ThpFaultAlloc int64 `json:"thpFaultAlloc"`
Unevictable int64 `json:"unevictable"`
WorkingSetActivate int64 `json:"workingsetActivate"`
WorkingSetNoReclaim int64 `json:"workingsetNodereclaim"`
WorkingSetRefault int64 `json:"workingsetRefault"`
} `json:"stats"`
Limit int64 `json:"limit"`
} `json:"memoryStats"`
Networks struct {
Eth0 struct {
RxBytes int64 `json:"rxBytes"`
RxPackets int64 `json:"rxPackets"`
RxErrors int64 `json:"rxErrors"`
RxDropped int64 `json:"rxDropped"`
TxBytes int64 `json:"txBytes"`
TxPackets int64 `json:"txPackets"`
TxErrors int64 `json:"txErrors"`
TxDropped int64 `json:"txDropped"`
} `json:"eth0"`
} `json:"networks"`
}
func (*ContainerStats) FormatCpuUsagePercentage ¶
func (stats *ContainerStats) FormatCpuUsagePercentage() string
func (*ContainerStats) FormatDiskIO ¶
func (stats *ContainerStats) FormatDiskIO() string
func (*ContainerStats) FormatMemoryUsage ¶
func (stats *ContainerStats) FormatMemoryUsage() string
func (*ContainerStats) FormatNetworkIO ¶
func (stats *ContainerStats) FormatNetworkIO() string
type FormatedContainerStats ¶
type ImageProgress ¶
type ImageProgress struct {
Status string `json:"status"`
ID string `json:"id,omitempty"`
Progress string `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
}
ImageProgress represents the JSON output from Docker image operations
type LogCopier ¶ added in v1.0.1
type LogCopier struct {
// contains filtered or unexported fields
}
LogCopier provides methods to copy Docker container logs
func NewLogCopier ¶ added in v1.0.1
NewLogCopier creates a new LogCopier instance If stderr is nil, it will use stdout for both streams
func (*LogCopier) Copy ¶ added in v1.0.1
Copy copies the container log stream to the configured writers It handles Docker's multiplexed output format where stdout and stderr are combined with headers
func (*LogCopier) CopyWithPrefix ¶ added in v1.0.1
func (lc *LogCopier) CopyWithPrefix(src io.Reader, stdoutPrefix, stderrPrefix string) (written int64, err error)
CopyWithPrefix copies the container log stream and adds prefixes to stdout and stderr This is useful when you want to distinguish between the two streams in the output