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 is shelled out to rather than using the Docker SDK: the SDK adds a large dependency tree and an API-version negotiation problem, and every operation needed here is one command whose flags are worth reading in full.
Index ¶
- Variables
- func CreateArgv(rs sandbox.RunSpec, o Options, name, network string) ([]string, error)
- func NetworkArgv(name string) []string
- func OwnerLabel() string
- func ProxyArgv(network, name, baseTag string) []string
- func RunArgv(rs sandbox.RunSpec, o Options, name, network string) ([]string, error)
- type Driver
- func (d *Driver) EnsureBase(ctx context.Context, slim bool) error
- func (d *Driver) HardwareIsolated() bool
- func (d *Driver) Name() string
- func (d *Driver) Prepare(ctx context.Context, e sandbox.EnvSpec) (sandbox.ImageRef, error)
- func (d *Driver) Run(ctx context.Context, rs sandbox.RunSpec) (sandbox.RunResult, error)
- func (d *Driver) Snapshot(context.Context, sandbox.ImageRef) (sandbox.SnapshotRef, error)
- func (d *Driver) Sweep(ctx context.Context)
- type Options
Constants ¶
This section is empty.
Variables ¶
ErrDockerUnavailable is returned when no usable docker binary was found.
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 ¶
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 ¶
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.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the Docker sandbox driver.
func (*Driver) EnsureBase ¶
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 ¶
HardwareIsolated reports false: runc shares the host kernel.
func (*Driver) Prepare ¶
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 ¶
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.