docker

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package docker wraps Docker Go SDK for internal usage in deber

Index

Constants

View Source
const (
	// ContainerStopTimeout constant represents how long Docker Engine
	// will wait for container before stopping it
	ContainerStopTimeout = 2

	// ContainerStateRunning constants defines that container is running
	ContainerStateRunning = "running"
	// ContainerStateCreated constants defines that container is created
	ContainerStateCreated = "created"
	// ContainerStateExited constants defines that container has exited
	ContainerStateExited = "exited"
	// ContainerStateRestarting constants defines that container is restarting
	ContainerStateRestarting = "restarting"
	// ContainerStatePaused constants defines that container is paused
	ContainerStatePaused = "paused"
	// ContainerStateDead constants defines that container is dead
	ContainerStateDead = "dead"
)
View Source
const (
	// APIVersion constant is the minimum supported version of Docker Engine API
	APIVersion = "1.40"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerCreateArgs

type ContainerCreateArgs struct {
	Mounts []mount.Mount
	Image  string
	Name   string
	User   string
}

ContainerCreateArgs struct represents arguments passed to ContainerCreate().

type ContainerExecArgs

type ContainerExecArgs struct {
	Interactive bool
	Name        string
	Cmd         string
	WorkDir     string
	AsRoot      bool
	Skip        bool
	Network     bool
}

ContainerExecArgs struct represents arguments passed to ContainerExec().

type Docker

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

Docker struct represents Docker client.

func New

func New() (*Docker, error)

New function creates fresh Docker struct and connects to Docker Engine.

func (*Docker) ContainerCreate

func (docker *Docker) ContainerCreate(args ContainerCreateArgs) error

ContainerCreate function creates container.

It's up to the caller to make to-be-mounted directories on host.

func (*Docker) ContainerExec

func (docker *Docker) ContainerExec(args ContainerExecArgs) error

ContainerExec function executes a command in running container.

Command is executed in bash shell by default.

Command can be executed as root.

Command can be executed interactively.

Command can be empty, in that case just bash is executed.

func (*Docker) ContainerExecResize

func (docker *Docker) ContainerExecResize(execID string, fd uintptr) error

ContainerExecResize function resizes TTY for exec process.

func (*Docker) ContainerList

func (docker *Docker) ContainerList(prefix string) ([]string, error)

ContainerList returns a list of containers that match passed criteria.

func (*Docker) ContainerMounts

func (docker *Docker) ContainerMounts(name string) ([]mount.Mount, error)

ContainerMounts returns mounts of created container.

func (*Docker) ContainerNetwork

func (docker *Docker) ContainerNetwork(name string, wantConnected bool) error

ContainerNetwork checks if container is connected to network and then connects it or disconnects per caller request.

func (*Docker) ContainerRemove

func (docker *Docker) ContainerRemove(name string) error

ContainerRemove function removes container, just that.

func (*Docker) ContainerStart

func (docker *Docker) ContainerStart(name string) error

ContainerStart function starts container, just that.

func (*Docker) ContainerStop

func (docker *Docker) ContainerStop(name string) error

ContainerStop function stops container, just that.

It utilizes ContainerStopTimeout constant.

func (*Docker) ImageAge

func (docker *Docker) ImageAge(name string) (time.Duration, error)

ImageAge function returns the time since image creation.

func (*Docker) ImageBuild

func (docker *Docker) ImageBuild(name string, dockerFile []byte) error

ImageBuild function build image from dockerfile and prints output to Stdout.

func (*Docker) ImageList

func (docker *Docker) ImageList(prefix string) ([]string, error)

ImageList returns a list of images that match passed criteria.

func (*Docker) ImageRemove

func (docker *Docker) ImageRemove(name string) error

ImageRemove function removes image with given name.

func (*Docker) IsContainerCreated

func (docker *Docker) IsContainerCreated(name string) (bool, error)

IsContainerCreated function checks if container is created or simply just exists.

func (*Docker) IsContainerStarted

func (docker *Docker) IsContainerStarted(name string) (bool, error)

IsContainerStarted function checks if container's state == ContainerStateRunning.

func (*Docker) IsContainerStopped

func (docker *Docker) IsContainerStopped(name string) (bool, error)

IsContainerStopped function checks if container's state != ContainerStateRunning.

func (*Docker) IsImageBuilt

func (docker *Docker) IsImageBuilt(name string) (bool, error)

IsImageBuilt function check if image with given name is built.

Jump to

Keyboard shortcuts

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