docker

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package docker implements the sandbox driver on the Docker CLI. It is the OSS default: self-hosted, own-team skills, and no infrastructure beyond a daemon that is already present. It is not sufficient isolation for untrusted code — containers share the host kernel — which is why sandbox.CheckPolicy refuses untrusted work here rather than this package deciding case by case.

The CLI rather than the SDK: the SDK adds a large dependency tree and an API-version negotiation problem, and every operation here is one command.

Index

Constants

This section is empty.

Variables

View Source
var ErrDockerUnavailable = errors.New("docker: no usable docker binary")
View Source
var SweepMinAge = time.Minute

SweepMinAge is how long an orphaned resource must have existed before Sweep removes it. A var so tests can shrink it.

Functions

func CreateArgv

func CreateArgv(rs sandbox.RunSpec, o Options, name, network string) ([]string, error)

CreateArgv is the "docker create" command line Run issues. No --rm: removal is explicit so "docker wait" can read the exit code before the container is gone.

func NetworkArgv

func NetworkArgv(name string) []string

NetworkArgv creates the private --internal network. --internal removes the default route, so egress is possible only through the proxy container.

func OwnerLabel

func OwnerLabel() string

OwnerLabel is the "key=value" filter matching this process's resources. Per-process so concurrent test binaries do not race each other.

func ProxyArgv

func ProxyArgv(network, name, baseTag string) []string

ProxyArgv starts the allowlist proxy, detached. Runs as root with only SETUID/SETGID because tinyproxy drops to nobody after binding its port.

func RunArgv

func RunArgv(rs sandbox.RunSpec, o Options, name, network string) ([]string, error)

RunArgv is the "docker run" command line. Run itself uses CreateArgv; this is exported for argv_test.go assertions on the security posture.

Types

type Driver

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

func New

func New(o Options) (*Driver, error)

func (*Driver) EnsureBase

func (d *Driver) EnsureBase(ctx context.Context, slim bool) error

EnsureBase builds the base image if its tag is absent. It is separate from Prepare because the base is shared across every skill and takes minutes, while a per-skill layer takes seconds.

func (*Driver) HardwareIsolated

func (d *Driver) HardwareIsolated() bool

HardwareIsolated reports false: runc shares the host kernel.

func (*Driver) Name

func (d *Driver) Name() string

func (*Driver) Prepare

func (d *Driver) Prepare(ctx context.Context, e sandbox.EnvSpec) (sandbox.ImageRef, error)

Prepare builds the per-skill layer, or reuses it when its content-addressed tag already exists. The tag is the deps digest, so "already built" and "identical contents" are the same question.

func (*Driver) Run

Run executes one command. A non-zero exit is a result, not an error. Uses create + start -a + wait (not "docker run") so the exit code comes from "docker wait" on its own channel, unambiguous from docker's own 125/ 126/127 failures.

func (*Driver) Snapshot

Snapshot is a no-op. Docker has no checkpoint/restore path worth relying on, so a run rebuilds from the prepared layer, which is already cached.

func (*Driver) Sweep

func (d *Driver) Sweep(ctx context.Context)

Sweep removes whetstone-labeled containers and networks whose creating process is no longer alive. Call once per eval, before any run starts. A resource is removed only when its pid is confirmed dead AND it is older than SweepMinAge. A live pid is never touched regardless of age.

type Options

type Options struct {
	Binary    string
	BaseTag   string
	CPUs      string
	Memory    string
	PidsLimit int
	Logger    func(format string, args ...any)
}

Options configures the driver. The limits are per run: a 60-session tier at concurrency four must not exhaust the host.

Jump to

Keyboard shortcuts

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