Help us shape the future of Go! Take the 2026 Go Developer Survey

daemon

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package daemon wires the engine together: the image store, the root filesystems built from it, and the container manager. The API server is a thin HTTP face over it.

Index

Constants

This section is empty.

Variables

View Source
var ErrImageInUse = errors.New("image is being used by a container")

ErrImageInUse is returned when removing an image a container uses.

View Source
var ErrNoSuchImage = errors.New("no such image")

ErrNoSuchImage is returned for an unknown image reference.

Functions

func ExecConfig

func ExecConfig(img *image.Image) image.ExecConfig

ExecConfig returns the run configuration an image declares. A wasm artifact has none; its single module is the entrypoint.

Types

type CreateRequest

type CreateRequest struct {
	Name       string
	Image      string
	Entrypoint []string // nil = image's
	Cmd        []string // nil = image's
	Env        []string
	WorkingDir string
	Labels     map[string]string
	Memory     int64
	AutoRemove bool
}

CreateRequest is a container create, with Docker's override rules: a set Entrypoint replaces the image's and drops its Cmd; a set Cmd replaces the image's Cmd; Env entries override the image's by key.

type Daemon

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

Daemon is one engine instance.

func New

func New(opt Options) (*Daemon, error)

New opens the store under opt.Root.

func (*Daemon) Close

func (d *Daemon) Close(ctx context.Context) error

Close kills running containers.

func (*Daemon) Containers

func (d *Daemon) Containers() *container.Manager

Containers is the container manager.

func (*Daemon) CreateContainer

func (d *Daemon) CreateContainer(req CreateRequest) (*container.Container, error)

CreateContainer makes a container from an image.

func (*Daemon) DiskUsage added in v0.4.0

func (d *Daemon) DiskUsage() (DiskUsage, error)

DiskUsage measures images (each once, however many names it has), containers' writable layers, and the state store.

func (*Daemon) Images

func (d *Daemon) Images() ([]ImageInfo, error)

Images lists images, one entry per image ID, newest first.

func (*Daemon) PruneImages added in v0.4.0

func (d *Daemon) PruneImages(all bool) ([]DeleteItem, int64, error)

PruneImages removes images no container uses; without all only dangling (unnamed) ones, which this store never keeps, so nothing.

func (*Daemon) Pull

func (d *Daemon) Pull(ctx context.Context, ref string, progress image.Progress) (string, *image.PullResult, error)

Pull fetches ref and names it; it returns the local name.

func (*Daemon) RemoveImage

func (d *Daemon) RemoveImage(ref string, force bool) ([]DeleteItem, error)

RemoveImage untags ref (or every name of an image given by ID) and deletes the image's blobs once no name is left. An image a container uses is refused unless force.

func (*Daemon) ResolveImage

func (d *Daemon) ResolveImage(ref string) (string, *image.Image, error)

ResolveImage finds an image by name ("hello", "hello:v1", "localhost:5000/x@sha256:…"), by ID ("sha256:…") or by unique ID prefix.

func (*Daemon) Restored added in v0.4.0

func (d *Daemon) Restored() container.RestoreReport

Restored says what was restored from the state store at start.

func (*Daemon) Storage added in v0.4.0

func (d *Daemon) Storage() StorageInfo

Storage describes the state store: what the embedder reports (Options.StorageInfo), plus the last failure to write to it.

type DeleteItem

type DeleteItem struct {
	Untagged string
	Deleted  string
}

DeleteItem is one line of an image removal.

type DiskUsage added in v0.4.0

type DiskUsage struct {
	LayersSize int64
	Images     []ImageInfo
	Containers []container.Snapshot
	Storage    StorageInfo
}

DiskUsage is what `system df` reports.

type ImageInfo

type ImageInfo struct {
	ID          image.Digest
	RepoTags    []string
	RepoDigests []string
	Created     time.Time
	Size        int64
	Labels      map[string]string
	Containers  int
	Image       *image.Image
}

ImageInfo is one image as `docker images` lists it.

type Options

type Options struct {
	// Root holds the image store on disk. One of Root and Backend is
	// required.
	Root string
	// Backend holds the image store elsewhere (memory, IndexedDB).
	Backend image.Backend
	// Limits bound pulls; zero means image.DefaultLimits.
	Limits image.Limits
	// Unpack bounds layer unpacking; zero means rootfs.DefaultLimits.
	Unpack rootfs.Limits
	// Registry configures registry pulls.
	Registry image.RegistryOptions
	// Containers configures the container manager (Executor required).
	Containers container.Options
	// MaxLowers bounds how many unpacked image trees stay in memory.
	MaxLowers int
	// StorageInfo, when set, reports the state store's usage for
	// `system df` (a browser's quota estimate, a disk's free space).
	StorageInfo func() StorageInfo
	// ImagesRemoved, when set, is called after images were deleted (the
	// browser executor drops its compiled-module cache then).
	ImagesRemoved func()
}

Options configures a daemon.

type StorageInfo added in v0.4.0

type StorageInfo struct {
	Kind         string
	Usage, Quota int64 // bytes, -1 unknown
	Persistent   bool
	Error        string
}

StorageInfo is where the engine keeps its state and how full it is.

Jump to

Keyboard shortcuts

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