docker

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package docker implements driver.ComputeDriver via the Docker Engine API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceRequestsForGPU

func DeviceRequestsForGPU(spec driver.Spec) []container.DeviceRequest

DeviceRequestsForGPU builds Docker CDI DeviceRequests for a Spec (nil if GPU off).

func ParseMemoryBytes

func ParseMemoryBytes(s string) (int64, error)

ParseMemoryBytes parses Docker-style memory strings (512m, 4g, …).

func SeccompNote

func SeccompNote() string

SeccompNote documents the MVP harden posture for health / spike notes.

Types

type Driver

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

Driver talks to a local Docker Engine / Desktop daemon.

func New

func New() (*Driver, error)

New returns a Docker compute driver using DOCKER_* env (FromEnv).

func NewFromClient

func NewFromClient(cli *client.Client) *Driver

NewFromClient wraps an existing client (tests).

func (*Driver) Close

func (d *Driver) Close() error

Close releases the underlying HTTP client.

func (*Driver) ContainerIP

func (d *Driver) ContainerIP(ctx context.Context, containerID, networkName string) (string, error)

ContainerIP returns the sandbox container IP on its osg network.

func (*Driver) CopyFrom

func (d *Driver) CopyFrom(ctx context.Context, id core.ID, srcPath, destHost string) error

CopyFrom reads a container path as tar and writes into destHost. If destHost exists as a directory (or ends with a path separator), entries are extracted under it. Otherwise a single regular file is written to destHost.

func (*Driver) CopyTo

func (d *Driver) CopyTo(ctx context.Context, id core.ID, srcHost, destPath string) error

CopyTo tars srcHost and extracts at destPath inside the container. For a single file, destPath is the full guest path (basename used in the tar). For a directory, destPath is the guest parent directory under which src's basename appears.

func (*Driver) Create

func (d *Driver) Create(ctx context.Context, spec driver.Spec) (driver.Handle, error)

Create ensures network + optional proxy sidecar + sandbox container (not started).

func (*Driver) Delete

func (d *Driver) Delete(ctx context.Context, id core.ID) error

Delete removes sandbox container, proxy sidecar, osg network, and data volume.

func (*Driver) EnsureSSHDaemon

func (d *Driver) EnsureSSHDaemon(ctx context.Context, id core.ID, authorizedKey string) error

EnsureSSHDaemon starts /osg/osg-sshd inside the guest if labeled for SSH.

func (*Driver) Exec

func (d *Driver) Exec(ctx context.Context, id core.ID, req driver.ExecRequest) (driver.ExecResult, error)

Exec runs a command in the container. With TTY, attaches stdin/stdout in raw mode. When the sandbox was created with osg-init, argv is wrapped: osg-init -- <cmd>.

Docker ContainerExecCreate Env replaces the process environment when non-empty. We always merge the container's Config.Env first so HTTP_PROXY / CA / HOME from create survive (otherwise `osg exec` / create `-- agent` cannot reach the sidecar).

func (*Driver) Health

func (d *Driver) Health(ctx context.Context) Probe

Health probes the daemon (Ping + ServerVersion + Info).

func (*Driver) ImagePresent

func (d *Driver) ImagePresent(ctx context.Context, ref string) bool

ImagePresent reports whether ref exists locally (no pull).

func (*Driver) Inspect

func (d *Driver) Inspect(ctx context.Context, nameOrID string) (driver.Info, error)

Inspect resolves by sandbox name or container id/prefix.

func (*Driver) List

func (d *Driver) List(ctx context.Context) ([]driver.Info, error)

List returns osg sandbox containers (excludes proxy sidecars).

func (*Driver) Logs

func (d *Driver) Logs(ctx context.Context, id core.ID, follow bool, w io.Writer) error

Logs streams stdout/stderr from the sandbox container and, when present, the egress proxy sidecar (where OCSF agent-observation events are emitted). When follow is true, starts from the last 500 lines per container.

func (*Driver) PolicyHostPath

func (d *Driver) PolicyHostPath(ctx context.Context, nameOrID string) (string, error)

PolicyHostPath returns the host path of the sandbox policy bind (label osg.policy_path).

func (*Driver) RunProbe

func (d *Driver) RunProbe(ctx context.Context, initBin string) (string, error)

RunProbe runs osg-init --probe in a one-shot helper container (Landlock ABI).

func (*Driver) SSHPort

func (d *Driver) SSHPort(ctx context.Context, id core.ID) (int, error)

SSHPort returns the host port bound to guest GuestSSHPort.

func (*Driver) Start

func (d *Driver) Start(ctx context.Context, id core.ID) error

Start starts a created container and seeds persist dirs when applicable.

func (*Driver) Stop

func (d *Driver) Stop(ctx context.Context, id core.ID) error

Stop stops a running container.

type Probe

type Probe struct {
	OK              bool
	ServerVersion   string
	APIVersion      string
	OperatingSystem string
	Architecture    string
	Context         string
	Isolation       string
	HostGOOS        string
	Error           string
}

Probe is a host-side Docker readiness report for `osg health`.

Jump to

Keyboard shortcuts

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