Documentation
¶
Overview ¶
Package api is the engine's API, compatible with a subset of the Docker Engine API (v1.47): what wctrd serves on a unix socket, and the client wctr speaks it with. Shapes follow the v1.47 OpenAPI document (see docs/REFERENCES.md); only the fields the engine fills are present.
The client side (types, Client, stdcopy) imports neither the daemon nor wazero, so the wctr command builds for wasip1.
Index ¶
- Constants
- Variables
- func DefaultHost() string
- func Demux(stdout, stderr io.Writer, r io.Reader) error
- func IsNotFound(err error) bool
- func WriteFrame(w io.Writer, stream byte, p []byte) error
- type Client
- func (c *Client) Changes(ctx context.Context, id string) ([]FilesystemChange, error)
- func (c *Client) Containers(ctx context.Context, all bool) ([]ContainerSummary, error)
- func (c *Client) Create(ctx context.Context, name string, req ContainerCreateRequest) (ContainerCreateResponse, error)
- func (c *Client) DiskUsage(ctx context.Context) (SystemDataUsage, error)
- func (c *Client) ImageInspect(ctx context.Context, ref string) (json.RawMessage, error)
- func (c *Client) Images(ctx context.Context) ([]ImageSummary, error)
- func (c *Client) Inspect(ctx context.Context, id string) (json.RawMessage, error)
- func (c *Client) Kill(ctx context.Context, id string) error
- func (c *Client) Logs(ctx context.Context, id string, follow bool) (io.ReadCloser, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) PruneContainers(ctx context.Context) (ContainerPruneResponse, error)
- func (c *Client) PruneImages(ctx context.Context, all bool) (ImagePruneResponse, error)
- func (c *Client) Pull(ctx context.Context, ref string, progress func(JSONMessage)) error
- func (c *Client) Remove(ctx context.Context, id string, force bool) error
- func (c *Client) RemoveImage(ctx context.Context, ref string, force bool) ([]ImageDeleteResponseItem, error)
- func (c *Client) Start(ctx context.Context, id string) error
- func (c *Client) Version(ctx context.Context) (SystemVersion, error)
- func (c *Client) Wait(ctx context.Context, id, condition string) (*Waiter, error)
- type ContainerConfig
- type ContainerCreateRequest
- type ContainerCreateResponse
- type ContainerInspect
- type ContainerPruneResponse
- type ContainerState
- type ContainerSummary
- type ContainerWaitExitError
- type ContainerWaitResponse
- type ErrDaemon
- type ErrorResponse
- type FilesystemChange
- type HostConfig
- type ImageDeleteResponseItem
- type ImageInspect
- type ImagePruneResponse
- type ImageSummary
- type JSONMessage
- type JSONMsgError
- type StorageUsage
- type StrSlice
- type SystemDataUsage
- type SystemVersion
- type Waiter
Constants ¶
const ( StreamStdin byte = 0 StreamStdout byte = 1 StreamStderr byte = 2 )
Stream types of the multiplexed stream.
const ( APIVersion = "1.47" MinAPIVersion = "1.24" )
APIVersion is the version the server speaks; MinAPIVersion the oldest it accepts in a /vX.Y prefix.
const DefaultSocket = "/var/run/wctr.sock"
DefaultSocket is where wctrd listens and wctr connects when neither -H nor WCTR_HOST says otherwise.
const HostEnv = "WCTR_HOST"
HostEnv names the environment variable that overrides the daemon host.
Variables ¶
var ErrBadFrame = errors.New("malformed multiplexed stream")
ErrBadFrame is returned for a malformed multiplexed stream.
Functions ¶
func DefaultHost ¶
func DefaultHost() string
DefaultHost is $WCTR_HOST if set, else unix:// + DefaultSocket.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client speaks the API to a daemon.
func NewClientWith ¶
NewClientWith uses a caller-provided HTTP client and base URL (tests, and later the browser's own transport).
func (*Client) Containers ¶
Containers lists containers.
func (*Client) Create ¶
func (c *Client) Create(ctx context.Context, name string, req ContainerCreateRequest) (ContainerCreateResponse, error)
Create creates a container.
func (*Client) DiskUsage ¶ added in v0.4.0
func (c *Client) DiskUsage(ctx context.Context) (SystemDataUsage, error)
DiskUsage is GET /system/df.
func (*Client) ImageInspect ¶
ImageInspect inspects an image.
func (*Client) Images ¶
func (c *Client) Images(ctx context.Context) ([]ImageSummary, error)
Images lists images.
func (*Client) PruneContainers ¶ added in v0.4.0
func (c *Client) PruneContainers(ctx context.Context) (ContainerPruneResponse, error)
PruneContainers removes every stopped container.
func (*Client) PruneImages ¶ added in v0.4.0
PruneImages removes dangling images, or with all every image no container uses.
func (*Client) Pull ¶
Pull pulls ref, calling progress for each message; an error message in the stream is returned as an error.
func (*Client) RemoveImage ¶
func (c *Client) RemoveImage(ctx context.Context, ref string, force bool) ([]ImageDeleteResponseItem, error)
RemoveImage removes an image.
type ContainerConfig ¶
type ContainerConfig struct {
Image string `json:"Image"`
Cmd StrSlice `json:"Cmd"`
Entrypoint StrSlice `json:"Entrypoint"`
Env []string `json:"Env"`
WorkingDir string `json:"WorkingDir"`
Labels map[string]string `json:"Labels"`
Tty bool `json:"Tty"`
}
ContainerConfig is the create body's container part.
type ContainerCreateRequest ¶
type ContainerCreateRequest struct {
ContainerConfig
HostConfig HostConfig `json:"HostConfig"`
}
ContainerCreateRequest is the body of POST /containers/create.
type ContainerCreateResponse ¶
ContainerCreateResponse is the reply to POST /containers/create.
type ContainerInspect ¶
type ContainerInspect struct {
ID string `json:"Id"`
Created string `json:"Created"`
Path string `json:"Path"`
Args []string `json:"Args"`
State ContainerState `json:"State"`
Image string `json:"Image"`
Name string `json:"Name"`
RestartCount int `json:"RestartCount"`
Driver string `json:"Driver"`
Platform string `json:"Platform"`
SizeRw int64 `json:"SizeRw"`
Config ContainerConfig `json:"Config"`
HostConfig HostConfig `json:"HostConfig"`
}
ContainerInspect is GET /containers/{id}/json (a subset).
type ContainerPruneResponse ¶ added in v0.4.0
type ContainerPruneResponse struct {
ContainersDeleted []string `json:"ContainersDeleted"`
SpaceReclaimed int64 `json:"SpaceReclaimed"`
}
ContainerPruneResponse is POST /containers/prune.
type ContainerState ¶
type ContainerState struct {
Status string `json:"Status"`
Running bool `json:"Running"`
Paused bool `json:"Paused"`
Restarting bool `json:"Restarting"`
OOMKilled bool `json:"OOMKilled"`
Dead bool `json:"Dead"`
Pid int `json:"Pid"`
ExitCode int `json:"ExitCode"`
Error string `json:"Error"`
StartedAt string `json:"StartedAt"`
FinishedAt string `json:"FinishedAt"`
}
ContainerState is the State of an inspect reply.
type ContainerSummary ¶
type ContainerSummary struct {
ID string `json:"Id"`
Names []string `json:"Names"`
Image string `json:"Image"`
ImageID string `json:"ImageID"`
Command string `json:"Command"`
Created int64 `json:"Created"`
Ports []any `json:"Ports"`
SizeRw int64 `json:"SizeRw,omitempty"`
Labels map[string]string `json:"Labels"`
State string `json:"State"`
Status string `json:"Status"`
HostConfig struct {
NetworkMode string `json:"NetworkMode"`
} `json:"HostConfig"`
}
ContainerSummary is one entry of GET /containers/json.
type ContainerWaitExitError ¶
type ContainerWaitExitError struct {
Message string `json:"Message"`
}
ContainerWaitExitError is the error part of a wait reply.
type ContainerWaitResponse ¶
type ContainerWaitResponse struct {
StatusCode int64 `json:"StatusCode"`
Error *ContainerWaitExitError `json:"Error"`
}
ContainerWaitResponse is the reply to POST /containers/{id}/wait.
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
ErrorResponse is the body of every error.
type FilesystemChange ¶ added in v0.4.0
FilesystemChange is one entry of GET /containers/{id}/changes; Kind is 0 modified, 1 added, 2 deleted.
type HostConfig ¶
HostConfig is the create body's host part (a subset).
type ImageDeleteResponseItem ¶
type ImageDeleteResponseItem struct {
Untagged string `json:"Untagged,omitempty"`
Deleted string `json:"Deleted,omitempty"`
}
ImageDeleteResponseItem is one entry of DELETE /images/{name}.
type ImageInspect ¶
type ImageInspect struct {
ID string `json:"Id"`
RepoTags []string `json:"RepoTags"`
RepoDigests []string `json:"RepoDigests"`
Created string `json:"Created"`
Author string `json:"Author"`
Architecture string `json:"Architecture"`
Os string `json:"Os"`
Size int64 `json:"Size"`
Config ContainerConfig `json:"Config"`
RootFS map[string]any `json:"RootFS"`
Metadata map[string]any `json:"Metadata,omitempty"`
Descriptor *json.RawMessage `json:"Descriptor,omitempty"`
}
ImageInspect is GET /images/{name}/json (a subset).
type ImagePruneResponse ¶ added in v0.4.0
type ImagePruneResponse struct {
ImagesDeleted []ImageDeleteResponseItem `json:"ImagesDeleted"`
SpaceReclaimed int64 `json:"SpaceReclaimed"`
}
ImagePruneResponse is POST /images/prune.
type ImageSummary ¶
type ImageSummary struct {
ID string `json:"Id"`
ParentID string `json:"ParentId"`
RepoTags []string `json:"RepoTags"`
RepoDigests []string `json:"RepoDigests"`
Created int64 `json:"Created"`
Size int64 `json:"Size"`
Labels map[string]string `json:"Labels"`
Containers int64 `json:"Containers"`
}
ImageSummary is one entry of GET /images/json.
type JSONMessage ¶
type JSONMessage struct {
Status string `json:"status,omitempty"`
ID string `json:"id,omitempty"`
Error string `json:"error,omitempty"`
ErrorDetail *JSONMsgError `json:"errorDetail,omitempty"`
}
JSONMessage is one line of the POST /images/create progress stream.
type JSONMsgError ¶
type JSONMsgError struct {
Message string `json:"message"`
}
JSONMsgError is the error detail of a JSONMessage.
type StorageUsage ¶ added in v0.4.0
type StorageUsage struct {
// Kind names the store: "directory /var/lib/wctr", "IndexedDB".
Kind string `json:"Kind"`
// Usage and Quota are bytes (-1: unknown); a browser reports its
// estimate for the whole origin.
Usage int64 `json:"Usage"`
Quota int64 `json:"Quota"`
// Persistent says the browser will not evict it under pressure.
Persistent bool `json:"Persistent"`
// Error is the last failure to store the engine's state, if any.
Error string `json:"Error,omitempty"`
}
StorageUsage describes the engine's storage (see SystemDataUsage).
type StrSlice ¶
type StrSlice []string
StrSlice accepts a JSON string or array of strings, as Docker's does for Cmd and Entrypoint; null stays nil ("use the image's").
func (*StrSlice) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type SystemDataUsage ¶ added in v0.4.0
type SystemDataUsage struct {
LayersSize int64 `json:"LayersSize"`
Images []ImageSummary `json:"Images"`
Containers []ContainerSummary `json:"Containers"`
Volumes []any `json:"Volumes"`
BuildCache []any `json:"BuildCache"`
// Storage is this engine's own addition: where its state lives and
// how full that is. Docker clients ignore it.
Storage *StorageUsage `json:"Storage,omitempty"`
}
SystemDataUsage is GET /system/df.
type SystemVersion ¶
type SystemVersion struct {
Platform struct{ Name string } `json:"Platform"`
Version string `json:"Version"`
APIVersion string `json:"ApiVersion"`
MinAPIVersion string `json:"MinAPIVersion"`
GitCommit string `json:"GitCommit"`
GoVersion string `json:"GoVersion"`
Os string `json:"Os"`
Arch string `json:"Arch"`
KernelVersion string `json:"KernelVersion"`
BuildTime string `json:"BuildTime,omitempty"`
}
SystemVersion is GET /version.
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
Waiter is a registered wait: the daemon has acknowledged it, and Result blocks until the condition holds.
func (*Waiter) Result ¶
func (w *Waiter) Result() (ContainerWaitResponse, error)
Result blocks for the wait's answer.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package inproc carries HTTP requests to a handler in the same process, with no socket: the browser has no unix sockets, so the playground's wctr talks to its engine through this transport instead.
|
Package inproc carries HTTP requests to a handler in the same process, with no socket: the browser has no unix sockets, so the playground's wctr talks to its engine through this transport instead. |
|
Package server serves the engine's Docker Engine API subset over HTTP.
|
Package server serves the engine's Docker Engine API subset over HTTP. |