Documentation
¶
Index ¶
- func IsConflict(err error) bool
- func IsNotFound(err error) bool
- type APIError
- type BuildOpt
- type Client
- func (c *Client) Build(ctx context.Context, buildCtx io.Reader, opts ...BuildOpt) error
- func (c *Client) Close() error
- func (c *Client) ConnectNetwork(ctx context.Context, networkID, containerID string) error
- func (c *Client) ContainerService() containers.Store
- func (c *Client) Containers(ctx context.Context, opts ...ListOpt) ([]Container, error)
- func (c *Client) CreateNetwork(ctx context.Context, name string, opts ...NetworkOpt) (network.Network, error)
- func (c *Client) CreateVolume(ctx context.Context, name string, opts ...VolumeOpt) (volume.Volume, error)
- func (c *Client) DeleteImage(ctx context.Context, ref string, opts ...ImageDeleteOpt) error
- func (c *Client) DeleteNetwork(ctx context.Context, id string) error
- func (c *Client) DeleteVolume(ctx context.Context, name string) error
- func (c *Client) DisconnectNetwork(ctx context.Context, networkID, containerID string, force bool) error
- func (c *Client) DiskUsage(ctx context.Context) (system.DiskUsage, error)
- func (c *Client) Events(ctx context.Context, opts ...EventsOpt) (<-chan system.Event, <-chan error)
- func (c *Client) GetImage(ctx context.Context, ref string) (Image, error)
- func (c *Client) ImageService() images.Store
- func (c *Client) Info(ctx context.Context) (system.Info, error)
- func (c *Client) InspectNetwork(ctx context.Context, id string) (network.Network, error)
- func (c *Client) InspectVolume(ctx context.Context, name string) (volume.Volume, error)
- func (c *Client) IsServing(ctx context.Context) (bool, error)
- func (c *Client) ListImages(ctx context.Context, opts ...ImageListOpt) ([]Image, error)
- func (c *Client) ListNetworks(ctx context.Context) ([]network.Network, error)
- func (c *Client) ListVolumes(ctx context.Context) ([]volume.Volume, error)
- func (c *Client) LoadContainer(ctx context.Context, id string) (Container, error)
- func (c *Client) NewContainer(ctx context.Context, id string, opts ...CreateOpt) (Container, error)
- func (c *Client) PruneContainers(ctx context.Context) ([]string, error)
- func (c *Client) PruneImages(ctx context.Context) error
- func (c *Client) PruneNetworks(ctx context.Context) error
- func (c *Client) PruneVolumes(ctx context.Context) error
- func (c *Client) Pull(ctx context.Context, ref string, opts ...PullOpt) (Image, error)
- func (c *Client) Push(ctx context.Context, ref string, opts ...PushOpt) error
- func (c *Client) RegistryLogin(ctx context.Context, username, password, server string) error
- func (c *Client) TagImage(ctx context.Context, source, target string) error
- func (c *Client) Version(ctx context.Context) (system.Version, error)
- type ConflictError
- type Container
- type CreateOpt
- func WithAutoRemove() CreateOpt
- func WithCmd(cmd ...string) CreateOpt
- func WithDNS(nameservers ...string) CreateOpt
- func WithDNSSearch(domains ...string) CreateOpt
- func WithEntrypoint(ep ...string) CreateOpt
- func WithEnv(key, value string) CreateOpt
- func WithHostname(hostname string) CreateOpt
- func WithImage(image string) CreateOpt
- func WithInteractive() CreateOpt
- func WithLabel(key, value string) CreateOpt
- func WithMount(m mount.Mount) CreateOpt
- func WithName(name string) CreateOpt
- func WithNetwork(name string) CreateOpt
- func WithPlatform(platform string) CreateOpt
- func WithPublish(hostPort, containerPort uint16, proto string) CreateOpt
- func WithTTY() CreateOpt
- func WithUser(user string) CreateOpt
- func WithVolume(hostPath, containerPath string) CreateOpt
- func WithWorkdir(dir string) CreateOpt
- type DeleteOpt
- type EventsOpt
- type ExecOpt
- type ExecResult
- type Image
- type ImageDeleteOpt
- type ImageListOpt
- type KillOpt
- type ListOpt
- type LogsOpt
- type NetworkOpt
- type NotFoundError
- type Opt
- type PullOpt
- type PushOpt
- type RestartOpt
- type StartOpt
- type StatsOpt
- type StopOpt
- type VolumeOpt
- type WaitResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConflict ¶
IsConflict returns true if the error is a ConflictError or a 409 APIError.
func IsNotFound ¶
IsNotFound returns true if the error is a NotFoundError or a 404 APIError.
Types ¶
type BuildOpt ¶
type BuildOpt func(*buildConfig)
BuildOpt configures image build.
func WithBuildTag ¶
WithBuildTag sets the tag for the built image.
func WithDockerfile ¶
WithDockerfile sets the Dockerfile path within the build context.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with Apple Container via the socktainer Docker-compatible API.
func New ¶
New creates a Client that connects to a socktainer Unix socket. By default it connects to $HOME/.socktainer/container.sock. Use WithSocketPath to override.
func (*Client) ConnectNetwork ¶
ConnectNetwork connects a container to a network.
func (*Client) ContainerService ¶
func (c *Client) ContainerService() containers.Store
ContainerService returns a Store backed by the Docker API.
func (*Client) Containers ¶
Containers lists containers. Pass WithListAll() to include stopped containers.
func (*Client) CreateNetwork ¶
func (c *Client) CreateNetwork(ctx context.Context, name string, opts ...NetworkOpt) (network.Network, error)
CreateNetwork creates a new network.
func (*Client) CreateVolume ¶
func (c *Client) CreateVolume(ctx context.Context, name string, opts ...VolumeOpt) (volume.Volume, error)
CreateVolume creates a new volume.
func (*Client) DeleteImage ¶
DeleteImage removes an image by reference.
func (*Client) DeleteNetwork ¶
DeleteNetwork removes a network.
func (*Client) DeleteVolume ¶
DeleteVolume removes a volume.
func (*Client) DisconnectNetwork ¶
func (c *Client) DisconnectNetwork(ctx context.Context, networkID, containerID string, force bool) error
DisconnectNetwork disconnects a container from a network.
func (*Client) Events ¶
Events returns a channel of engine events. The channel closes when the context is cancelled.
func (*Client) ImageService ¶
ImageService returns a Store backed by the Docker API.
func (*Client) InspectNetwork ¶
InspectNetwork returns details of a network.
func (*Client) InspectVolume ¶
InspectVolume returns details of a volume.
func (*Client) ListImages ¶
ListImages returns all local images.
func (*Client) ListNetworks ¶
ListNetworks lists all networks.
func (*Client) ListVolumes ¶
ListVolumes lists all volumes.
func (*Client) LoadContainer ¶
LoadContainer returns a handle to an existing container by ID.
func (*Client) NewContainer ¶
NewContainer creates a new container and returns a handle to it.
func (*Client) PruneContainers ¶
PruneContainers removes all stopped containers.
func (*Client) PruneImages ¶
PruneImages removes unused images.
func (*Client) PruneNetworks ¶
PruneNetworks removes unused networks.
func (*Client) PruneVolumes ¶
PruneVolumes removes unused volumes.
func (*Client) RegistryLogin ¶
RegistryLogin authenticates with a container registry.
type ConflictError ¶
ConflictError indicates a resource state conflict.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type Container ¶
type Container interface {
ID() string
Info(ctx context.Context) (containers.Container, error)
Start(ctx context.Context, opts ...StartOpt) error
Stop(ctx context.Context, opts ...StopOpt) error
Kill(ctx context.Context, opts ...KillOpt) error
Delete(ctx context.Context, opts ...DeleteOpt) error
Restart(ctx context.Context, opts ...RestartOpt) error
Wait(ctx context.Context, condition string) (<-chan WaitResult, <-chan error)
Exec(ctx context.Context, cmd []string, opts ...ExecOpt) (ExecResult, error)
Logs(ctx context.Context, opts ...LogsOpt) (io.ReadCloser, error)
Stats(ctx context.Context, opts ...StatsOpt) (system.Stats, error)
Inspect(ctx context.Context) (containers.Container, error)
Image(ctx context.Context) (Image, error)
Labels(ctx context.Context) (map[string]string, error)
}
Container represents a handle to a container managed by Apple Container.
type CreateOpt ¶
type CreateOpt func(*createConfig) error
CreateOpt configures container creation.
func WithAutoRemove ¶
func WithAutoRemove() CreateOpt
WithAutoRemove removes the container when it stops.
func WithDNSSearch ¶
WithDNSSearch sets DNS search domains.
func WithEntrypoint ¶
WithEntrypoint overrides the image entrypoint.
func WithHostname ¶
WithHostname sets the container hostname.
func WithNetwork ¶
WithNetwork attaches the container to a network.
func WithPlatform ¶
WithPlatform sets the platform (e.g. "linux/arm64").
func WithPublish ¶
WithPublish adds a port mapping.
func WithVolume ¶
WithVolume adds a bind mount.
type DeleteOpt ¶
type DeleteOpt func(*deleteConfig)
DeleteOpt configures container deletion.
func WithForceDelete ¶
func WithForceDelete() DeleteOpt
WithForceDelete forces removal of a running container.
func WithRemoveVolumes ¶
func WithRemoveVolumes() DeleteOpt
WithRemoveVolumes removes associated volumes.
type EventsOpt ¶
type EventsOpt func(*eventsConfig)
EventsOpt configures event subscription.
func WithEventFilters ¶
WithEventFilters sets a raw Docker filters JSON string for events.
type ExecResult ¶
type ExecResult struct {
ExecID string
Output io.ReadCloser
}
ExecResult holds the output of an exec command.
type Image ¶
type Image interface {
Name() string
ID() string
RepoTags() []string
RepoDigests() []string
Labels() map[string]string
Size() int64
Created() time.Time
Info(ctx context.Context) (images.Image, error)
Delete(ctx context.Context, opts ...ImageDeleteOpt) error
Tag(ctx context.Context, repo, tag string) error
}
Image represents a handle to a container image.
type ImageDeleteOpt ¶
type ImageDeleteOpt func(*imageDeleteConfig)
ImageDeleteOpt configures image deletion.
type KillOpt ¶
type KillOpt func(*killConfig)
KillOpt configures container kill behavior.
func WithKillSignal ¶
WithKillSignal sets the signal to send (default KILL).
type ListOpt ¶
type ListOpt func(*listConfig)
ListOpt configures container listing.
func WithListFilters ¶
WithListFilters sets a raw Docker filters JSON string.
type LogsOpt ¶
type LogsOpt func(*logsConfig)
LogsOpt configures container log retrieval.
func WithLogsSince ¶
WithLogsSince shows logs since a timestamp.
func WithLogsTTY ¶
func WithLogsTTY() LogsOpt
WithLogsTTY indicates the container has a TTY (raw log stream).
func WithLogsTail ¶
WithLogsTail limits the number of lines from the end.
type NetworkOpt ¶
type NetworkOpt func(*networkConfig)
NetworkOpt configures network creation.
func WithNetworkGateway ¶
func WithNetworkGateway(gw string) NetworkOpt
WithNetworkGateway sets the gateway for the network.
func WithNetworkLabel ¶
func WithNetworkLabel(key, value string) NetworkOpt
WithNetworkLabel adds a label to the network.
func WithNetworkSubnet ¶
func WithNetworkSubnet(subnet string) NetworkOpt
WithNetworkSubnet sets the subnet for the network.
type NotFoundError ¶
NotFoundError indicates the requested resource was not found.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Opt ¶
type Opt func(*clientOpts) error
Opt configures a Client.
func WithAPIVersion ¶
WithAPIVersion overrides the Docker API version prefix (default "v1.51").
func WithSocketPath ¶
WithSocketPath sets the Unix socket path to connect to. Default: $HOME/.socktainer/container.sock
func WithTimeout ¶
WithTimeout sets a default timeout for API calls.
type PullOpt ¶
type PullOpt func(*pullConfig)
PullOpt configures image pull.
func WithPullPlatform ¶
WithPullPlatform sets the platform for the pull.
type RestartOpt ¶
type RestartOpt func(*restartConfig)
RestartOpt configures container restart.
func WithRestartTimeout ¶
func WithRestartTimeout(seconds int) RestartOpt
WithRestartTimeout sets the seconds to wait before killing during restart.
type StopOpt ¶
type StopOpt func(*stopConfig)
StopOpt configures container stop behavior.
func WithStopSignal ¶
WithStopSignal sets the signal to send (default SIGTERM).
func WithStopTimeout ¶
WithStopTimeout sets the seconds to wait before killing.
type VolumeOpt ¶
type VolumeOpt func(*volumeConfig)
VolumeOpt configures volume creation.
func WithVolumeDriver ¶
WithVolumeDriver sets the volume driver.
func WithVolumeLabel ¶
WithVolumeLabel adds a label to the volume.
type WaitResult ¶
type WaitResult struct {
StatusCode int64
}
WaitResult holds the outcome of a container wait.