docker

package
v0.0.0-...-7220889 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartCommandString

func StartCommandString(containerName string, req *ContainerArgs) string

StartCommandString prints the command used in Start to spin up a container Uses the same underlying logic as Start to ensure we always print an accurate string

Types

type Client

type Client interface {
	Pull(ctx context.Context, imageName string, timeout time.Duration) error
	Start(ctx context.Context, containerName string, req *ContainerArgs, timeout time.Duration) (*StartResponse, error)
	IsUp(ctx context.Context, containerName string) (bool, error)
	Remove(ctx context.Context, containerName string, force bool) error
	Exec(ctx context.Context, containerName string, req *ExecRequest) (*ExecResponse, error)
	IPAddress(ctx context.Context, containerName string) (string, error)
	CopyTo(ctx context.Context, containerName string, sourcePath, destinationPath string) error
	CopyFrom(ctx context.Context, containerName string, sourcePath, destinationPath string) error
	PrintAll(ctx context.Context) error
}

Client wraps interface to docker communication.

func NewClient

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

NewClient creates client to work with docker client.

type ContainerArgs

type ContainerArgs struct {
	// Run container in detached mode.
	// Detached container are not wait till the process will be finished.
	Detached     bool
	ImageName    string
	PublishPorts []string
	ExposePorts  []string
	EnvVar       []string
	Volumes      []string
	Network      string
	Privileged   bool
	Exec         []string
}

ContainerArgs holds info to start container.

type ExecRequest

type ExecRequest struct {
	Cmd     []string
	Timeout time.Duration
}

ExecRequest holds data to perform request.

type ExecResponse

type ExecResponse struct {
	// Exit code of execution.
	// Negative exit codes are reserved for internal use.
	ExitCode int
	Stdout   string
	Stderr   string
}

ExecResponse holds result of the execution.

type StartResponse

type StartResponse struct {
	// Exit code of execution.
	// Negative exit codes are reserved for internal use.
	ExitCode int
	Stdout   string
	Stderr   string
}

StartResponse holds result data from starting the container.

Jump to

Keyboard shortcuts

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