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) ContainerCommit(ctx context.Context, containerConfig *container.ContainerConfig, ...) (string, error)
- func (c *Client) ContainerDiff(ctx context.Context, containerConfig *container.ContainerConfig) ([]Diff, error)
- func (c *Client) ContainerExecAttach(ctx context.Context, containerConfig *container.ContainerConfig, ...) (*types.HijackedResponse, error)
- func (c *Client) ContainerExecAttachTerminal(ctx context.Context, containerConfig *container.ContainerConfig, ...) (*terminal.Session, error)
- func (c *Client) ContainerExecInspect(ctx context.Context, containerConfig *container.ContainerConfig, ...) (*ExecInspect, error)
- func (c *Client) ContainerExecResize(ctx context.Context, containerConfig *container.ContainerConfig, ...) error
- func (c *Client) ContainerExecStart(ctx context.Context, containerConfig *container.ContainerConfig, ...) error
- func (c *Client) ContainerExport(ctx context.Context, containerConfig *container.ContainerConfig) (io.ReadCloser, error)
- func (c *Client) ContainerGetStatsChan(ctx context.Context, containerConfig *container.ContainerConfig) (<-chan ContainerStats, <-chan error)
- func (c *Client) ContainerGetStatsOneShot(ctx context.Context, containerConfig *container.ContainerConfig) (ContainerStats, error)
- func (c *Client) ContainerInspect(ctx context.Context, containerConfig *container.ContainerConfig) (types.ContainerJSON, error)
- func (c *Client) ContainerKill(ctx context.Context, containerConfig *container.ContainerConfig, signal string) error
- func (c *Client) ContainerList(ctx context.Context, listOptionFns ...ListOptionFn) ([]ListedContainer, error)
- func (c *Client) ContainerPause(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) ContainerPrune(ctx context.Context, pruneOptions ...PruneOptionFn) (PruneResponse, error)
- func (c *Client) ContainerRename(ctx context.Context, containerConfig *container.ContainerConfig, ...) error
- func (c *Client) ContainerTop(ctx context.Context, containerConfig *container.ContainerConfig, ...) (ContainerTop, error)
- func (c *Client) ContainerUnpause(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) ContainerUpdate(ctx context.Context, containerConfig *container.ContainerConfig, ...) (warnings []string, err 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) GetContainerExitCode(ctx context.Context, containerConfig *container.ContainerConfig) (int, 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) GetImageCreatedTime(ctx context.Context, imageConfig *image.ImageConfig) (string, error)
- func (c *Client) GetImageSize(ctx context.Context, imageConfig *image.ImageConfig) (int64, error)
- func (c *Client) GetNetworkContainers(ctx context.Context, networkConfig *network.NetworkConfig) ([]string, error)
- func (c *Client) GetVolumeUsage(ctx context.Context, volumeConfig *volume.VolumeConfig) (int64, error)
- func (c *Client) IsContainerRunning(ctx context.Context, containerConfig *container.ContainerConfig) (bool, error)
- func (c *Client) IsNetworkExists(ctx context.Context, networkConfig *network.NetworkConfig) (bool, error)
- func (c *Client) IsVolumeExists(ctx context.Context, volumeConfig *volume.VolumeConfig) (bool, 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) PruneImages(ctx context.Context, pruneOptions ...PruneOptionFn) (ImagePruneResponse, 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) PullImageIfNotPresent(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) RunAndWait(ctx context.Context, containerConfig *container.ContainerConfig) error
- func (c *Client) RunAsync(ctx context.Context, containerConfig *container.ContainerConfig) (<-chan error, 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 ContainerTop
- type Diff
- type ExecInspect
- type FormatedContainerStats
- type ImageProgress
- type ImagePruneResponse
- type ListOptionFn
- type ListedContainer
- type LogCopier
- type NetworkStats
- type PruneOptionFn
- type PruneResponse
- type UpdateOptionFn
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) ContainerCommit ¶ added in v1.0.2
func (c *Client) ContainerCommit(ctx context.Context, containerConfig *container.ContainerConfig, imageConfig *image.ImageConfig, commitOptions ...commitoptions.CommitOptionsFn) (string, error)
ContainerCommit applies changes to a container and creates a new tagged image.
func (*Client) ContainerDiff ¶ added in v1.0.2
func (c *Client) ContainerDiff(ctx context.Context, containerConfig *container.ContainerConfig) ([]Diff, error)
ContainerDiff returns the changes on a container's filesystem.
func (*Client) ContainerExecAttach ¶ added in v1.0.2
func (c *Client) ContainerExecAttach(ctx context.Context, containerConfig *container.ContainerConfig, execConfig *exec.ExecConfig) (*types.HijackedResponse, error)
ContainerExecAttach attaches to a container exec command and returns a hijacked response that can be used to read the output of the exec command. It is up to the caller to close the hijacked response.
func (*Client) ContainerExecAttachTerminal ¶ added in v1.0.2
func (c *Client) ContainerExecAttachTerminal(ctx context.Context, containerConfig *container.ContainerConfig, execConfig *exec.ExecConfig) (*terminal.Session, error)
ContainerExecAttachTerminal attaches to a container exec command and returns a terminal session that can be used to interact with the command. The session handles terminal setup, raw mode, and cleanup automatically.
func (*Client) ContainerExecInspect ¶ added in v1.0.2
func (c *Client) ContainerExecInspect(ctx context.Context, containerConfig *container.ContainerConfig, execConfig *exec.ExecConfig) (*ExecInspect, error)
ContainerExecInspect returns information about a container exec command.
func (*Client) ContainerExecResize ¶ added in v1.0.2
func (c *Client) ContainerExecResize(ctx context.Context, containerConfig *container.ContainerConfig, execConfig *exec.ExecConfig, height, width uint) error
ContainerExecResize resizes the TTY of a container exec command.
func (*Client) ContainerExecStart ¶ added in v1.0.2
func (c *Client) ContainerExecStart(ctx context.Context, containerConfig *container.ContainerConfig, execConfig *exec.ExecConfig) error
func (*Client) ContainerExport ¶ added in v1.0.2
func (c *Client) ContainerExport(ctx context.Context, containerConfig *container.ContainerConfig) (io.ReadCloser, error)
ContainerExport retrieves the raw contents of a container and returns them as an io.ReadCloser. It's up to the caller to close the stream.
func (*Client) ContainerGetStatsChan ¶ added in v1.0.2
func (c *Client) ContainerGetStatsChan(ctx context.Context, containerConfig *container.ContainerConfig) (<-chan ContainerStats, <-chan error)
ContainerGetStatsChan returns near realtime stats for a given container. It is a blocking call that will not return until either: - The context is cancelled - The container is stopped - An error occurs Use context with timeout or cancellation to control the maximum wait time.
func (*Client) ContainerGetStatsOneShot ¶ added in v1.0.2
func (c *Client) ContainerGetStatsOneShot(ctx context.Context, containerConfig *container.ContainerConfig) (ContainerStats, error)
ContainerStatsOneShot gets a single stat entry from a container. It differs from `ContainerStats` in that the API should not wait to prime the stats
func (*Client) ContainerInspect ¶ added in v1.0.2
func (c *Client) ContainerInspect(ctx context.Context, containerConfig *container.ContainerConfig) (types.ContainerJSON, error)
ContainerInspect returns the JSON representation of a container. It returns docker's ContainerJSON type.
func (*Client) ContainerKill ¶ added in v1.0.2
func (c *Client) ContainerKill(ctx context.Context, containerConfig *container.ContainerConfig, signal string) error
ContainerKill kills a container.
func (*Client) ContainerList ¶ added in v1.0.2
func (c *Client) ContainerList(ctx context.Context, listOptionFns ...ListOptionFn) ([]ListedContainer, error)
func (*Client) ContainerPause ¶ added in v1.0.2
func (c *Client) ContainerPause(ctx context.Context, containerConfig *container.ContainerConfig) error
ContainerPause pauses a container.
func (*Client) ContainerPrune ¶ added in v1.0.2
func (c *Client) ContainerPrune(ctx context.Context, pruneOptions ...PruneOptionFn) (PruneResponse, error)
ContainerPrune prunes containers based on the provided options. It returns a PruneResponse containing the space reclaimed and the containers deleted. It uses the filters.Args type to build the filter for the prune operation.
func (*Client) ContainerRename ¶ added in v1.0.2
func (c *Client) ContainerRename(ctx context.Context, containerConfig *container.ContainerConfig, newName string) error
ContainerRename renames a container.
func (*Client) ContainerTop ¶ added in v1.0.2
func (c *Client) ContainerTop(ctx context.Context, containerConfig *container.ContainerConfig, psArgs []string) (ContainerTop, error)
ContainerTop returns the top process information for a container.
func (*Client) ContainerUnpause ¶ added in v1.0.2
func (c *Client) ContainerUnpause(ctx context.Context, containerConfig *container.ContainerConfig) error
ContainerUnpause unpauses a container.
func (*Client) ContainerUpdate ¶ added in v1.0.2
func (c *Client) ContainerUpdate(ctx context.Context, containerConfig *container.ContainerConfig, updateOptions ...UpdateOptionFn) (warnings []string, err error)
ContainerUpdate updates a container with new configuration.
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) GetContainerExitCode ¶ added in v1.0.2
func (c *Client) GetContainerExitCode(ctx context.Context, containerConfig *container.ContainerConfig) (int, error)
GetContainerExitCode returns the exit code of a container
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) GetImageCreatedTime ¶ added in v1.0.2
func (c *Client) GetImageCreatedTime(ctx context.Context, imageConfig *image.ImageConfig) (string, error)
GetImageCreatedTime returns when the image was created
func (*Client) GetImageSize ¶ added in v1.0.2
GetImageSize returns the size of an image in bytes
func (*Client) GetNetworkContainers ¶ added in v1.0.2
func (c *Client) GetNetworkContainers(ctx context.Context, networkConfig *network.NetworkConfig) ([]string, error)
GetNetworkContainers returns a list of container IDs connected to a network
func (*Client) GetVolumeUsage ¶ added in v1.0.2
func (c *Client) GetVolumeUsage(ctx context.Context, volumeConfig *volume.VolumeConfig) (int64, error)
GetVolumeUsage returns the size of a volume in bytes if available
func (*Client) IsContainerRunning ¶ added in v1.0.2
func (c *Client) IsContainerRunning(ctx context.Context, containerConfig *container.ContainerConfig) (bool, error)
IsContainerRunning checks if a container is currently running
func (*Client) IsNetworkExists ¶ added in v1.0.2
func (c *Client) IsNetworkExists(ctx context.Context, networkConfig *network.NetworkConfig) (bool, error)
IsNetworkExists checks if a network exists
func (*Client) IsVolumeExists ¶ added in v1.0.2
func (c *Client) IsVolumeExists(ctx context.Context, volumeConfig *volume.VolumeConfig) (bool, error)
IsVolumeExists checks if a volume exists
func (*Client) PauseContainer ¶
func (*Client) PruneImages ¶ added in v1.0.2
func (c *Client) PruneImages(ctx context.Context, pruneOptions ...PruneOptionFn) (ImagePruneResponse, error)
func (*Client) PruneVolumes ¶
func (*Client) PullImageIfNotPresent ¶ added in v1.0.2
PullImageIfNotPresent pulls an image only if it doesn't exist locally
func (*Client) RemoveContainer ¶
func (*Client) RemoveImage ¶
func (*Client) RemoveNetwork ¶
func (*Client) RemoveVolume ¶
func (*Client) RestartContainer ¶
func (*Client) RunAndWait ¶ added in v1.0.2
RunAndWait creates, starts a container and waits for it to finish. This is a blocking call that will not return until either: - The container finishes executing - An error occurs - The context is cancelled Use context with timeout or cancellation to control the maximum wait time.
func (*Client) RunAsync ¶ added in v1.0.2
func (c *Client) RunAsync(ctx context.Context, containerConfig *container.ContainerConfig) (<-chan error, error)
RunAsync creates and starts a container without waiting for it to finish. Returns a channel that will receive the container's exit error (if any). The channel will be closed when the container finishes.
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 {
Read time.Time `json:"read"`
Preread time.Time `json:"preread"`
PidsStats container.PidsStats `json:"pids_stats"`
BlkioStats container.BlkioStats `json:"blkio_stats"`
NumProcs int64 `json:"num_procs"`
StorageStats container.StorageStats `json:"storage_stats"`
CpuStats container.CPUStats `json:"cpu_stats"`
PreCPUStats container.CPUStats `json:"precpu_stats"`
MemoryStats container.MemoryStats `json:"memory_stats"`
Networks map[string]NetworkStats `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 ContainerTop ¶ added in v1.0.2
type ContainerTop struct {
// Each process running in the container, where each is process
// is an array of values corresponding to the titles.
//
// Required: true
Processes [][]string `json:"Processes"`
// The ps column titles
// Required: true
Titles []string `json:"Titles"`
}
ContainerTop is the response from the ContainerTop API.
type ExecInspect ¶ added in v1.0.2
type FormatedContainerStats ¶
type ImageProgress ¶
type ImageProgress struct {
Stream string `json:"stream,omitempty"`
Status string `json:"status,omitempty"`
Progress string `json:"progress,omitempty"`
Aux struct {
ID string `json:"id,omitempty"`
} `json:"aux,omitempty"`
ErrorDetail struct {
Message string `json:"message,omitempty"`
} `json:"errorDetail,omitempty"`
Error string `json:"error,omitempty"`
}
ImageProgress represents the JSON output from Docker image operations
type ImagePruneResponse ¶ added in v1.0.2
type ListOptionFn ¶ added in v1.0.2
type ListOptionFn func(*containerType.ListOptions)
type ListedContainer ¶ added in v1.0.2
type ListedContainer struct {
ID string `json:"Id,omitempty"`
Names []string `json:"Names,omitempty"`
Image string `json:"Image,omitempty"`
ImageID string `json:"ImageID,omitempty"`
Command string `json:"Command,omitempty"`
Created int64 `json:"Created,omitempty"`
Ports []types.Port `json:"Ports,omitempty"`
SizeRw int64 `json:"SizeRw,omitempty"`
SizeRootFs int64 `json:"SizeRootFs,omitempty"`
Labels map[string]string
State string `json:"State,omitempty"`
Status string `json:"Status,omitempty"`
HostConfig struct {
NetworkMode string `json:"NetworkMode,omitempty"`
Annotations map[string]string `json:"Annotations,omitempty"`
}
NetworkSettings *types.SummaryNetworkSettings `json:"NetworkSettings,omitempty"`
Mounts []types.MountPoint `json:"Mounts,omitempty"`
}
ListedContainer is the response from the ContainerList API.
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
type NetworkStats ¶ added in v1.0.2
type NetworkStats struct {
RxBytes uint64 `json:"rx_bytes"`
RxDropped uint64 `json:"rx_dropped"`
RxErrors uint64 `json:"rx_errors"`
RxPackets uint64 `json:"rx_packets"`
TxBytes uint64 `json:"tx_bytes"`
TxDropped uint64 `json:"tx_dropped"`
TxErrors uint64 `json:"tx_errors"`
TxPackets uint64 `json:"tx_packets"`
}
type PruneOptionFn ¶ added in v1.0.2
func WithPruneFilter ¶ added in v1.0.2
func WithPruneFilter(key, value string) PruneOptionFn
WithPruneFilter adds a filter to the prune operation.
type PruneResponse ¶ added in v1.0.2
type UpdateOptionFn ¶ added in v1.0.2
type UpdateOptionFn func(*containerType.UpdateConfig)
UpdateOptionFn is a function that can be used to update a container.