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
- Variables
- func ApplyChanges(c image.ExecConfig, changes []string) (image.ExecConfig, error)
- func ExecConfig(img *image.Image) image.ExecConfig
- func ParseBind(b string) (container.Mount, error)
- type CommitRequest
- type CommitResult
- type CreateRequest
- type Daemon
- func (d *Daemon) Close(ctx context.Context) error
- func (d *Daemon) Commit(req CommitRequest) (CommitResult, error)
- func (d *Daemon) Containers() *container.Manager
- func (d *Daemon) CreateContainer(req CreateRequest) (*container.Container, error)
- func (d *Daemon) CreateVolume(name string, labels map[string]string) (*volume.Volume, error)
- func (d *Daemon) DiskUsage() (DiskUsage, error)
- func (d *Daemon) Events() *events.Bus
- func (d *Daemon) Images() ([]ImageInfo, error)
- func (d *Daemon) Load(ctx context.Context, r io.Reader, progress image.Progress) ([]Loaded, error)
- func (d *Daemon) NetworkConnect(ctx context.Context, netRef, containerRef string, aliases []string) error
- func (d *Daemon) NetworkCreate(name string, labels map[string]string) (network.Network, error)
- func (d *Daemon) NetworkDisconnect(netRef, containerRef string) error
- func (d *Daemon) NetworkPrune(keep func(labels map[string]string) bool) []string
- func (d *Daemon) NetworkRemove(ref string) error
- func (d *Daemon) Networks() *network.Manager
- func (d *Daemon) PruneImages(all bool) ([]DeleteItem, int64, error)
- func (d *Daemon) PruneVolumes(all bool) ([]string, int64)
- func (d *Daemon) Pull(ctx context.Context, ref string, progress image.Progress) (string, *image.PullResult, error)
- func (d *Daemon) RemoveImage(ref string, force bool) ([]DeleteItem, error)
- func (d *Daemon) RemoveVolume(name string, force bool) error
- func (d *Daemon) ResolveImage(ref string) (string, *image.Image, error)
- func (d *Daemon) Restored() container.RestoreReport
- func (d *Daemon) Storage() StorageInfo
- func (d *Daemon) TagImage(source, repo, tag string) (string, error)
- func (d *Daemon) Volumes() *volume.Manager
- type DeleteItem
- type DiskUsage
- type ImageInfo
- type Loaded
- type Options
- type StorageInfo
Constants ¶
const MaxChanges = 64
MaxChanges bounds the instructions of one commit.
Variables ¶
var ErrImageInUse = errors.New("image is being used by a container")
ErrImageInUse is returned when removing an image a container uses.
var ErrNoSuchImage = errors.New("no such image")
ErrNoSuchImage is returned for an unknown image reference.
Functions ¶
func ApplyChanges ¶ added in v0.12.0
func ApplyChanges(c image.ExecConfig, changes []string) (image.ExecConfig, error)
ApplyChanges applies `commit --change` instructions (Dockerfile syntax, one per entry) to c: CMD, ENTRYPOINT, ENV, EXPOSE, LABEL, ONBUILD, STOPSIGNAL, USER, VOLUME, WORKDIR, as Docker's commit allows. CMD and ENTRYPOINT take the JSON (exec) form or the shell form, which becomes ["/bin/sh", "-c", "…"] as in a Dockerfile.
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 CommitRequest ¶ added in v0.12.0
type CommitRequest struct {
Container string
// Repo and Tag name the image; with no Repo it stays addressable by ID
// only (a <none> image).
Repo, Tag string
Comment string
Author string
// Config replaces the image config's "config" object (Docker's
// semantics: the whole object); nil keeps the parent's, with the
// container's command, environment, working directory and labels.
Config *image.ExecConfig
// Changes are Dockerfile instructions applied on top (commit -c).
Changes []string
}
CommitRequest is POST /commit: a container's changes as a new image.
type CommitResult ¶ added in v0.12.0
type CommitResult struct {
ID image.Digest // the config digest
Name string // empty for a <none> image
}
CommitResult is what a commit made.
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
// Binds are "VOLUME:/path[:ro|:rw]": named volumes only (a host path
// means nothing to a WebAssembly engine), created if missing.
Binds []string
// Network is the network to join by name or ID ("" or "default": the
// engine's default; "none": no network).
Network string
// Caps are device capabilities granted to the container ("gpu").
Caps []string
// Restart is the restart policy (HostConfig.RestartPolicy).
Restart container.RestartPolicy
// Healthcheck overrides the image's health check field by field (an
// empty Test, a zero duration or retry count: the image's).
Healthcheck *container.HealthConfig
// Endpoints are the networks' aliases by network (Docker's
// NetworkingConfig.EndpointsConfig); a network named there and not in
// Network is joined too (API 1.44+), and with no Network the first of
// them by name is the primary.
Endpoints map[string][]string
// Ports are published ports (HostConfig.PortBindings, run -p);
// ExposedPorts adds ports with no binding (Config.ExposedPorts, run
// --expose), to the image's own; PublishAll gives each of those a port
// the system picks (run -P).
Ports portmap.Map
ExposedPorts map[string]struct{}
PublishAll 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 (*Daemon) Commit ¶ added in v0.12.0
func (d *Daemon) Commit(req CommitRequest) (CommitResult, error)
Commit writes a container's changes as a new image: the parent's layers, plus one layer with the container's changes (OCI whiteouts) when there are any, and a config whose history records the commit (an empty one marked empty_layer). The image is proved to unpack before it is named.
func (*Daemon) Containers ¶
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) CreateVolume ¶ added in v0.8.0
CreateVolume makes a volume (or returns the existing one).
func (*Daemon) DiskUsage ¶ added in v0.4.0
DiskUsage measures images (each once, however many names it has), containers' writable layers, and the state store.
func (*Daemon) Load ¶ added in v0.12.0
Load stores every image of an OCI image layout sent as a tar (POST /images/load, what a builder exports): each index.json entry is pulled from the in-memory layout with every check a pull makes, proved to unpack, and named by its org.opencontainers.image.ref.name (a full image reference, or a tag of the layout's name). Nothing on the host is read.
func (*Daemon) NetworkConnect ¶ added in v0.14.0
func (d *Daemon) NetworkConnect(ctx context.Context, netRef, containerRef string, aliases []string) error
NetworkConnect puts a container on a network (network connect).
func (*Daemon) NetworkCreate ¶ added in v0.14.0
NetworkCreate makes an in-engine network.
func (*Daemon) NetworkDisconnect ¶ added in v0.14.0
NetworkDisconnect takes a container off a network (network disconnect).
func (*Daemon) NetworkPrune ¶ added in v0.14.0
NetworkPrune removes the created networks no container uses whose labels keep accepts (nil: all), and returns their names.
func (*Daemon) NetworkRemove ¶ added in v0.10.0
NetworkRemove removes a created network no container uses.
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) PruneVolumes ¶ added in v0.8.0
PruneVolumes removes unused anonymous volumes, or with all every unused one.
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) RemoveVolume ¶ added in v0.8.0
RemoveVolume deletes a volume no container uses; with force a missing one is not an error (Docker's meaning of force for volumes).
func (*Daemon) ResolveImage ¶
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 ¶
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 Loaded ¶ added in v0.12.0
Loaded is one image a load stored: its name (empty for an entry with no org.opencontainers.image.ref.name, kept as a <none> image) and ID.
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()
// Volumes configures named volumes (they share Containers.Store).
Volumes volume.Options
// Networks configures networks (they share Containers.Store); every
// engine has "bridge", its default, and "none".
Networks network.Options
}
Options configures a daemon.