godock

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(length int) string

func StatsFormatter

func StatsFormatter(writer io.Writer) *formater

Formats the incoming stats and passes it to the supplied writer

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context) (*Client, error)

func (*Client) BuildImage

func (c *Client) BuildImage(ctx context.Context, imageConfig *image.ImageConfig) error

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 (c *Client) CreateContainer(ctx context.Context, containerConfig *container.ContainerConfig) error

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(ctx context.Context, networkConfig *network.NetworkConfig) error

func (*Client) CreateVolume

func (c *Client) CreateVolume(ctx context.Context, volumeConfig *volume.VolumeConfig) error

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) error

GetContainerLogs gets logs and is synchronus

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) LoadImage

func (c *Client) LoadImage(ctx context.Context, inputFile string) error

func (*Client) PauseContainer

func (c *Client) PauseContainer(ctx context.Context, containerConfig *container.ContainerConfig) error

func (*Client) PruneVolumes

func (c *Client) PruneVolumes(ctx context.Context, filterMap map[string][]string) (uint64, error)

func (*Client) PullImage

func (c *Client) PullImage(ctx context.Context, imageConfig *image.ImageConfig) error

func (*Client) PushImage

func (c *Client) PushImage(ctx context.Context, imageConfig *image.ImageConfig) error

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(ctx context.Context, containerConfig *container.ContainerConfig, force bool) error

func (*Client) RemoveImage

func (c *Client) RemoveImage(ctx context.Context, imageConfig *image.ImageConfig, force bool) error

func (*Client) RemoveNetwork

func (c *Client) RemoveNetwork(ctx context.Context, networkConfig *network.NetworkConfig) error

func (*Client) RemoveVolume

func (c *Client) RemoveVolume(ctx context.Context, volumeConfig *volume.VolumeConfig) error

func (*Client) RestartContainer

func (c *Client) RestartContainer(ctx context.Context, containerConfig *container.ContainerConfig) error

func (*Client) SaveImage

func (c *Client) SaveImage(ctx context.Context, imageConfig *image.ImageConfig, outputFile string) error

func (*Client) SetImageResponeWriter

func (c *Client) SetImageResponeWriter(dst io.Writer)

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

func (c *Client) SetLogResponseWriter(dst io.Writer)

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

func (c *Client) SetStatsResponeWriter(dst io.Writer)

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 (c *Client) StartContainer(ctx context.Context, containerConfig *container.ContainerConfig) error

func (*Client) StopContainer

func (c *Client) StopContainer(ctx context.Context, containerConfig *container.ContainerConfig) error

func (*Client) String

func (c *Client) String() string

func (*Client) TagImage

func (c *Client) TagImage(ctx context.Context, imageConfig *image.ImageConfig, newTag string) error

func (*Client) UnpauseContainer

func (c *Client) UnpauseContainer(ctx context.Context, containerConfig *container.ContainerConfig) error

func (*Client) Unwrap

func (c *Client) Unwrap() client.APIClient

Unwraps the abstracted client for use with other docker packages

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 FormatedContainerStats struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	CpuUsage    string `json:"cpuUsage"`
	MemoryUsage string `json:"memoryUsage"`
	NetworkIO   string `json:"networkIO"`
	DiskIO      string `json:"diskIO"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL