Documentation
¶
Overview ¶
Package docker drives the local Docker Engine over its unix socket with the handful of calls a snapshot and a restore make: ensure an image by digest, create a container from a Spec, start, wait, stop, remove, inspect, read logs, list by label. Nothing else.
Index ¶
- Constants
- Variables
- func IsNotFound(err error) bool
- type APIError
- type Client
- func (c *Client) CheckInit(ctx context.Context) error
- func (c *Client) Create(ctx context.Context, spec Spec) (string, error)
- func (c *Client) EnsureImage(ctx context.Context, ref string, progress io.Writer) (Image, error)
- func (c *Client) Info(ctx context.Context) (Info, error)
- func (c *Client) Inspect(ctx context.Context, id string) (State, error)
- func (c *Client) InspectImage(ctx context.Context, ref string) (Image, error)
- func (c *Client) List(ctx context.Context, label string) ([]Summary, error)
- func (c *Client) Logs(ctx context.Context, id string, tail int, w io.Writer) error
- func (c *Client) Remove(ctx context.Context, id string) error
- func (c *Client) Start(ctx context.Context, id string) error
- func (c *Client) Stop(ctx context.Context, id string, grace time.Duration) error
- func (c *Client) Wait(ctx context.Context, id string) (int, error)
- type Image
- type Info
- type Mount
- type Spec
- type State
- type Summary
- type Version
Constants ¶
const ( // DefaultSocket is where Docker listens on Linux. DefaultSocket = "/var/run/docker.sock" // ManagedLabel marks every container warmctl creates. ManagedLabel = "io.warmctl.managed" )
const DefaultTmpSize = 1 << 30
DefaultTmpSize bounds a container's /tmp tmpfs.
const Hostname = "warmctl"
Hostname is every warmctl container's host name: a restored engine finds the one it was snapshotted under.
Variables ¶
var CheckpointCaps = []string{
"SYS_ADMIN", "SYS_PTRACE", "CHECKPOINT_RESTORE", "SYS_RESOURCE", "NET_ADMIN", "SYS_TIME", "DAC_READ_SEARCH",
}
CheckpointCaps are the capabilities of a checkpoint container. CRIU's link remaps use linkat(AT_EMPTY_PATH) on unlinked inodes, which needs DAC_READ_SEARCH even as root.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Version Version
// contains filtered or unexported fields
}
Client talks to one local daemon.
func (*Client) CheckInit ¶
CheckInit fails when the daemon names no init binary: warmctl's containers run docker-init as PID 1 (HostConfig.Init). The init commit is not checked: distribution builds leave it empty with a working init.
func (*Client) EnsureImage ¶
EnsureImage makes ref (name@sha256:...) present, pulling it when missing, and returns the local image. A tag without a digest is refused.
func (*Client) InspectImage ¶
InspectImage reads a local image by reference or ID.
func (*Client) List ¶
List returns the containers carrying label (key or key=value), running or not.
func (*Client) Logs ¶
Logs copies the container's stdout and stderr, the last tail lines when tail > 0, into w.
type Spec ¶
type Spec struct {
Name string
Image string
Entrypoint []string
Env map[string]string
Labels map[string]string
WorkingDir string
Mounts []Mount
// GPUs are device UUIDs in rank order.
GPUs []string
Memory int64
SHM int64
CPUs int
PIDs int64
// TmpSize bounds the /tmp tmpfs.
TmpSize int64
// Checkpoint grants what CRIU and cuda-checkpoint need inside the
// container: root, the checkpoint capabilities, no seccomp or AppArmor
// profile and a writable /proc/sys for the PID allocator.
Checkpoint bool
}
Spec is a container warmctl runs: the donor of a snapshot or the receiver of a restore.
type State ¶
type State struct {
ID string `json:"Id"`
Name string
Image string
Config struct{ Labels map[string]string }
State struct {
Status string
Running bool
Pid int
ExitCode int
Error string
OOMKilled bool
}
}
State is the part of an inspection warmctl reads.