cli

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DockerRun                    = "docker run"
	DockerContainerList          = "docker container list"
	DockerContainerInspect       = "docker container inspect"
	DockerContainerStop          = "docker container stop"
	DockerContainerStart         = "docker container start"
	DockerContainerInspectStatus = "docker container inspect -f '{{json .State}}'"

	ContainerStatusStopped = "exited"
	ContainerStatusRunning = "running"

	ErrContainerStopTimeout  = "the requested container did not stop within the requested time frame"
	ErrContainerStartTimeout = "the requested container did not start within the requested time frame"
)

Variables

This section is empty.

Functions

func RunCommand

func RunCommand(cmd string) (string, error)

Types

type DockerBackupVolumeParams

type DockerBackupVolumeParams struct {
	ContainerName  string
	BackupFolder   string
	BackupFilename string
	TargetFolder   string
}

type DockerCliClient

type DockerCliClient struct{}

This client requires the docker cli to be installed.

func NewDockerCliClient

func NewDockerCliClient() DockerCliClient

func (DockerCliClient) BackupDockerVolume

func (c DockerCliClient) BackupDockerVolume(params DockerBackupVolumeParams) (string, error)

func (DockerCliClient) InspectContainer

func (c DockerCliClient) InspectContainer(name string) (string, error)

func (DockerCliClient) InspectContainerStatus

func (c DockerCliClient) InspectContainerStatus(name string) (DockerContainerStatus, error)

func (DockerCliClient) IsRunning

func (c DockerCliClient) IsRunning(name string) bool

func (DockerCliClient) IsStopped

func (c DockerCliClient) IsStopped(name string) bool

func (DockerCliClient) ListContainers

func (c DockerCliClient) ListContainers() (string, error)

func (DockerCliClient) PollStartContainer

func (c DockerCliClient) PollStartContainer(name string) error

func (DockerCliClient) PollStopContainer

func (c DockerCliClient) PollStopContainer(name string) error

This will block the thread till the container has stopped. This will wait for a total of 60 seconds, if the container does not stop in time, we error out.

func (DockerCliClient) StartContainer

func (c DockerCliClient) StartContainer(name string) (string, error)

This sends the start command but does not wait for it to come online.

func (DockerCliClient) StopContainer

func (c DockerCliClient) StopContainer(name string) (string, error)

This sends the stop command but does not wait for it to go offline.

type DockerContainerStatus

type DockerContainerStatus struct {
	Status     string    `json:"Status"`
	Running    bool      `json:"Running"`
	Paused     bool      `json:"Paused"`
	Restarting bool      `json:"Restarting"`
	OOMKilled  bool      `json:"OOMKilled"`
	Dead       bool      `json:"Dead"`
	Pid        int       `json:"Pid"`
	ExitCode   int       `json:"ExitCode"`
	Error      string    `json:"Error"`
	StartedAt  time.Time `json:"StartedAt"`
	FinishedAt time.Time `json:"FinishedAt"`
}

Jump to

Keyboard shortcuts

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