docker

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docker runs the runner's throwaway containers and removes everything they leave behind.

Index

Constants

View Source
const (
	LabelRunner = "dev.backproof.runner"
	LabelJob    = "dev.backproof.job"
)

Labels carried by every container and volume the runner creates.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client creates and removes the containers of one runner.

func New

func New(runnerID string) (*Client, error)

New returns a client for the Docker daemon described by the environment.

func (*Client) Close

func (c *Client) Close() error

Close releases the connection to the Docker daemon.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks that the Docker daemon is reachable.

func (*Client) RemoveJob

func (c *Client) RemoveJob(ctx context.Context, jobID string) error

RemoveJob deletes every container and volume labelled with this runner and job.

func (*Client) RemoveOrphans

func (c *Client) RemoveOrphans(ctx context.Context, keepJobIDs ...string) error

RemoveOrphans deletes everything labelled with this runner, except what belongs to the given jobs. Other runners on the same Docker host keep their containers.

func (*Client) Start

func (c *Client) Start(ctx context.Context, spec ContainerSpec) (*Container, error)

Start pulls the image if needed and starts an isolated container. RemoveJob cleans up whatever exists if Start fails part of the way through.

type Container

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

Container is a running throwaway container.

func (*Container) Exec

func (c *Container) Exec(ctx context.Context, spec ExecSpec) (int, error)

Exec runs a command to completion and returns its exit code.

func (*Container) Remove

func (c *Container) Remove(ctx context.Context) error

Remove deletes this container and its volumes.

type ContainerSpec

type ContainerSpec struct {
	JobID      string
	Image      string
	Env        []string
	Entrypoint []string
	Cmd        []string
	Limits     Limits
}

ContainerSpec describes a throwaway container.

type ExecSpec

type ExecSpec struct {
	User   string
	Cmd    []string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

ExecSpec describes a command to run inside a container.

type Limits

type Limits struct {
	MemoryBytes int64
	NanoCPUs    int64
}

Limits caps what a container may use. Zero means no limit.

Jump to

Keyboard shortcuts

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