docker

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 16 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 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

View Source
const (

	// DefaultSocket is where Docker listens on Linux.
	DefaultSocket = "/var/run/docker.sock"
	// ManagedLabel marks every container warmctl creates.
	ManagedLabel = "io.warmctl.managed"
)
View Source
const DefaultTmpSize = 1 << 30

DefaultTmpSize bounds a container's /tmp tmpfs.

View Source
const Hostname = "warmctl"

Hostname is every warmctl container's host name: a restored engine finds the one it was snapshotted under.

Variables

View Source
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

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports a 404 answer.

Types

type APIError

type APIError struct {
	Status  int
	Message string
}

APIError is a non-2xx answer.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client talks to one local daemon.

func New

func New(ctx context.Context, socket string) (*Client, error)

New connects to the daemon at socket and checks it speaks API 1.45.

func (*Client) CheckInit

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

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) Create

func (c *Client) Create(ctx context.Context, spec Spec) (string, error)

Create makes a container from spec and returns its ID.

func (*Client) EnsureImage

func (c *Client) EnsureImage(ctx context.Context, ref string, progress io.Writer) (Image, error)

EnsureImage makes ref (name@sha256:...) present, pulling it when missing, and returns the local image. A tag without a digest is refused.

func (*Client) Info

func (c *Client) Info(ctx context.Context) (Info, error)

Info reads the daemon's facts.

func (*Client) Inspect

func (c *Client) Inspect(ctx context.Context, id string) (State, error)

Inspect reads a container's state.

func (*Client) InspectImage

func (c *Client) InspectImage(ctx context.Context, ref string) (Image, error)

InspectImage reads a local image by reference or ID.

func (*Client) List

func (c *Client) List(ctx context.Context, label string) ([]Summary, error)

List returns the containers carrying label (key or key=value), running or not.

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, id string, tail int, w io.Writer) error

Logs copies the container's stdout and stderr, the last tail lines when tail > 0, into w.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, id string) error

Remove force-removes the container. A missing container is not an error.

func (*Client) Start

func (c *Client) Start(ctx context.Context, id string) error

Start starts a created container.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context, id string, grace time.Duration) error

Stop sends SIGTERM, then SIGKILL after grace. A stopped or missing container is not an error.

func (*Client) Wait

func (c *Client) Wait(ctx context.Context, id string) (int, error)

Wait blocks until the container stops and returns its exit code.

type Image

type Image struct {
	ID           string `json:"Id"`
	RepoDigests  []string
	Os           string
	Architecture string
}

Image is what EnsureImage found.

type Info

type Info struct {
	InitBinary string
	Runtimes   map[string]any
}

Info is the part of /info warmctl reads.

type Mount

type Mount struct {
	Source   string
	Target   string
	ReadOnly bool
}

Mount is a bind mount.

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.

type Summary

type Summary struct {
	ID     string `json:"Id"`
	Names  []string
	State  string
	Labels map[string]string
}

Summary is one row of List.

type Version

type Version struct {
	Version       string
	APIVersion    string
	MinAPIVersion string
	Os            string
	Arch          string
}

Version is the daemon's /version answer.

Jump to

Keyboard shortcuts

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