docker

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client - digitalocean abstraction

func (*Client) CalculateStats

func (cl *Client) CalculateStats(jsonStats *types.StatsJSON) *models.Stats

CalculateStats - converting container stats into more easy readable stats

func (*Client) ContainerCreate

func (cl *Client) ContainerCreate(name string, config *container.Config, hostConfig *container.HostConfig, networkConfig *network.NetworkingConfig) (*container.ContainerCreateCreatedBody, error)

ContainerCreate - Creates a new container

func (*Client) ContainerGet

func (cl *Client) ContainerGet(containerID string) (*types.ContainerJSON, error)

ContainerGet insepcts a container

func (*Client) ContainerLogs

func (cl *Client) ContainerLogs(containerID string, tailNumberLines int, sinceTimestamp time.Time) (*models.DockerLogs, error)

ContainerLogs - retrurn last defined number of lines since timestamp (if larger than zero)

func (*Client) ContainerLogsStream

func (cl *Client) ContainerLogsStream(containerID string, output chan []byte, done chan bool) error

ContainerLogsStream streams logs from server until done channel received true

func (*Client) ContainerRemove added in v1.0.5

func (cl *Client) ContainerRemove(containerID string) error

ContainerRemove - removing the container. timeout in 10 seconds, force removing all

func (*Client) ContainerRename added in v1.0.5

func (cl *Client) ContainerRename(containerID string, newContainerName string) error

replaceRevert reverts the phases done by ContainerReplace function in case of errors

func (*Client) ContainerReplace added in v1.0.5

func (cl *Client) ContainerReplace(containerID string, image string, tag string) error

func (*Client) ContainerRestart

func (cl *Client) ContainerRestart(containerID string, waitForRestartLimit time.Duration) error

ContainerRestart - restarting a running container

func (*Client) ContainerStart

func (cl *Client) ContainerStart(containerID string) error

ContainerStart - start a created container

func (*Client) ContainerStats

func (cl *Client) ContainerStats(containerID string) (*types.StatsJSON, error)

ContainerStats - returns a snapshot of container stats in a moment it's called

func (*Client) ContainerStop

func (cl *Client) ContainerStop(containerID string, forceKillAfter *time.Duration) error

ContainerStop - stops the container

func (*Client) ContainersList

func (cl *Client) ContainersList() ([]types.Container, error)

ContainersList for all docker containers

func (*Client) ContainersListWithOptions

func (cl *Client) ContainersListWithOptions(opts types.ContainerListOptions) ([]types.Container, error)

ContainersListWithOptions list containers with various filters

func (*Client) ContainersPrune

func (cl *Client) ContainersPrune(pruneFilter filters.Args) (*types.ContainersPruneReport, error)

ContainersPrune - cleaning up non-running containers

func (*Client) GetDockerClient

func (cl *Client) GetDockerClient() *client.Client

GetDockerClient - return configured docker client

func (*Client) ImagePullDockerHub

func (cl *Client) ImagePullDockerHub(image, tag string, username, password string) (string, error)

ImagePullDockerHub - pull private image from docker hub (it waits for pull to finish)

func (*Client) ImageRemove

func (cl *Client) ImageRemove(imageID string) ([]types.ImageDeleteResponseItem, error)

ImageRemove - removes an image by force and prunes its children

func (*Client) ImagesList

func (cl *Client) ImagesList() ([]types.ImageSummary, error)

ImagesList - returns list of pulled images

func (*Client) SystemWideInfo added in v1.0.7

func (cl *Client) SystemWideInfo() (types.Info, types.DiskUsage, error)

func (*Client) VolumesPrune

func (cl *Client) VolumesPrune(pruneFilter filters.Args) (*types.VolumesPruneReport, error)

VolumesPrune - cleaning up non-attached volumes

type Docker

type Docker interface {
	ContainersList() ([]types.Container, error)
	ContainersListWithOptions(opts types.ContainerListOptions) ([]types.Container, error)
	ContainerLogs(containerID string, tailNumberLines int, sinceTimestamp time.Time) (*models.DockerLogs, error)

	// ContainerLogsStream streams logs to output channel until done is received. User is responsible to close the passed in channel
	ContainerLogsStream(containerID string, output chan []byte, done chan bool) error

	// Container CRUD operations
	ContainerCreate(name string, config *container.Config, hostConfig *container.HostConfig, networkConfig *network.NetworkingConfig) (*container.ContainerCreateCreatedBody, error)
	ContainerStart(containerID string) error
	ContainerRestart(containerID string, waitForRestartLimit time.Duration) error
	ContainersPrune(pruneFilter filters.Args) (*types.ContainersPruneReport, error)
	ContainerStop(containerID string, killAfterTimeout *time.Duration) error
	ContainerGet(containerID string) (*types.ContainerJSON, error)
	ContainerStats(containerID string) (*types.StatsJSON, error)
	ImagesList() ([]types.ImageSummary, error)
	ImagePullDockerHub(image, tag string, username, password string) (string, error)
	ImageRemove(imageID string) ([]types.ImageDeleteResponseItem, error)
	VolumesPrune(pruneFilter filters.Args) (*types.VolumesPruneReport, error)
	GetDockerClient() *client.Client
	CalculateStats(jsonStats *types.StatsJSON) *models.Stats
	ContainerRemove(containerID string) error
	ContainerRename(containerID string, newContainerName string) error
	ContainerReplace(containerID string, image string, tag string) error

	// host system information
	SystemWideInfo() (types.Info, types.DiskUsage, error)
}

Docker API interfaces

func NewLocalClient

func NewLocalClient(opts ...Option) Docker

NewLocalClient creates a client without TLS connection (recommended only if running on localhost)

func NewSocketClient

func NewSocketClient(opts ...Option) Docker

func NewTLSClient

func NewTLSClient(opts ...Option) Docker

NewTLSClient init digital ocean client

type Option

type Option func(*Options)

Option a single option

func APIVersion

func APIVersion(version string) Option

APIVersion - the remote docker API version

func CACert

func CACert(cacert []byte) Option

CACert - CA Client Certificate

func Cert

func Cert(cert []byte) Option

Cert - Client certificate

func CertKey

func CertKey(key []byte) Option

CertKey - Client certificate key

func Host

func Host(remoteHost string) Option

Host - remote host

func Log

func Log(log mclog.Logger) Option

Log - recommended to be enabled at all times

type Options

type Options struct {
	Log        mclog.Logger
	Host       string
	APIVersion string
	CACert     []byte
	KeyCert    []byte
	Cert       []byte
}

Options for docker client

Jump to

Keyboard shortcuts

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