Documentation
¶
Overview ¶
Package docker is the installer's client of the Docker Engine for what every Docker has: a Client that creates, finds and deletes networks, volumes, containers and images from their specs, one file per kind. What only a swarm has, services, tasks, configs and secrets, is the swarm package's. Around the Client: selecting objects, telling the installer's own, recognising the daemon's errors, and the settings both orchestrators convert alike.
Index ¶
- Constants
- func ByInstallation(installation installer.Installation) client.Filters
- func ByName(name string) client.Filters
- func Content(object types.FileObjectConfig) []byte
- func Environment(values types.MappingWithEquals) []string
- func Healthcheck(check *types.HealthCheckConfig) *container.HealthConfig
- func IsInUse(err error) bool
- func IsNotFound(err error) bool
- func NanoCPUs(cpus float32) int64
- func NotOwned(kind, name string, want map[string]string) error
- func Owns(objectLabels, want map[string]string) bool
- func Provision(directory string) error
- func SameVolume(existing, spec *volume.Volume) bool
- func Ulimits(limits map[string]*types.UlimitsConfig) []*container.Ulimit
- type Client
- func (docker *Client) API() client.APIClient
- func (docker *Client) Close() error
- func (docker *Client) ContainerCopy(ctx context.Context, id string, archive io.Reader) error
- func (docker *Client) ContainerCopyFrom(ctx context.Context, id, path string) (io.ReadCloser, error)
- func (docker *Client) ContainerCreate(ctx context.Context, options client.ContainerCreateOptions) (string, error)
- func (docker *Client) ContainerDelete(ctx context.Context, id string) error
- func (docker *Client) ContainerFollow(ctx context.Context, id string, output io.Writer) (<-chan struct{}, error)
- func (docker *Client) ContainerInspect(ctx context.Context, id string) (container.InspectResponse, error)
- func (docker *Client) ContainerList(ctx context.Context, filters client.Filters) ([]container.Summary, error)
- func (docker *Client) ContainerStart(ctx context.Context, id string) error
- func (docker *Client) ContainerWait(ctx context.Context, id string) (int64, error)
- func (docker *Client) ImageEnsure(ctx context.Context, image, policy, registryAuth string) error
- func (docker *Client) ImageInspect(ctx context.Context, image string) (image.InspectResponse, error)
- func (docker *Client) Info(ctx context.Context) (system.Info, error)
- func (docker *Client) NetworkCreate(ctx context.Context, spec NetworkSpec) error
- func (docker *Client) NetworkDelete(ctx context.Context, network *network.Summary) error
- func (docker *Client) NetworkFind(ctx context.Context, name string) (*network.Summary, error)
- func (docker *Client) VolumeCreate(ctx context.Context, spec *volume.Volume) error
- func (docker *Client) VolumeDelete(ctx context.Context, volume *volume.Volume) error
- func (docker *Client) VolumeFind(ctx context.Context, name string) (*volume.Volume, error)
- func (docker *Client) VolumeProvision(ctx context.Context, image, registryAuth string, ...) error
- type NetworkSpec
Constants ¶
const (
ProvisionCommand = "provision"
)
ProvisionCommand is the command of the installer's image that creates a directory, in the storage mounted at provisionMount: VolumeProvision runs it, and the image answers it with Provision.
Variables ¶
This section is empty.
Functions ¶
func ByInstallation ¶
func ByInstallation(installation installer.Installation) client.Filters
ByInstallation selects the objects of an installation, by their labels.
func ByName ¶
ByName selects objects whose name contains name. The daemon matches prefixes, so callers still compare the exact name.
func Content ¶
func Content(object types.FileObjectConfig) []byte
Content returns the content of a config or a secret, or nil for an external one, which is only referenced. installer.LoadProject has read every other one into its Content.
func Environment ¶
func Environment(values types.MappingWithEquals) []string
Environment returns the variables of a service, sorted, the way the daemon takes them: NAME=value, or NAME alone to pass it from the daemon.
func Healthcheck ¶
func Healthcheck(check *types.HealthCheckConfig) *container.HealthConfig
Healthcheck converts the healthcheck of a service.
func IsInUse ¶
IsInUse reports whether the daemon refused to remove an object because something still uses it: a network with endpoints, a config or a secret a service references, a volume a container mounts. The daemon gives no error kind for it, so the messages are matched.
func IsNotFound ¶
IsNotFound reports whether the daemon answered that the object does not exist.
func NanoCPUs ¶ added in v0.3.2
NanoCPUs converts cpus, as compose holds them, to the billionths of a CPU the daemon takes. A float32 holds 0.1 as 0.100000001490116, so the value goes through its shortest decimal form, the one the compose file wrote.
func NotOwned ¶
NotOwned is the error for an object of the project's name that is not the installer's own.
func Owns ¶
Owns reports whether an object the installer found by its name is its own: it carries every label of want. The installer only reuses, updates or removes its own objects; a name taken by anything else is an error.
func Provision ¶
Provision is the installer image's side of VolumeProvision: it creates the directory, which must be in the storage mounted at provisionMount.
func SameVolume ¶
SameVolume reports whether an existing volume has the driver and options the spec declares. No driver declared means the daemon's default, local.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client drives the Docker Engine of the target. Its methods take the specs the orchestrators convert the compose project into, find objects by their exact name, and name the object in their errors.
func Connect ¶
Connect connects to the Docker Engine of the environment: the socket the runtime mounted, with the io.cnab.docker extension, or DOCKER_HOST and its TLS settings when the installer runs away from the target.
func New ¶
New returns the client of an Engine API connection: the runtime's, which reaches the target the way the docker CLI does.
func (*Client) ContainerCopy ¶
ContainerCopy extracts a tar archive at the root of the container, keeping the owners the archive gives.
func (*Client) ContainerCopyFrom ¶
func (docker *Client) ContainerCopyFrom(ctx context.Context, id, path string) (io.ReadCloser, error)
ContainerCopyFrom returns a tar archive of the path in the container.
func (*Client) ContainerCreate ¶
func (*Client) ContainerDelete ¶
ContainerDelete stops the container and removes it.
func (*Client) ContainerFollow ¶
func (docker *Client) ContainerFollow(ctx context.Context, id string, output io.Writer) (<-chan struct{}, error)
ContainerFollow copies the container's output to output from the start, until it stops. Call it before ContainerStart, so nothing is missed. The channel closes once all of it is copied.
func (*Client) ContainerInspect ¶
func (*Client) ContainerList ¶
func (docker *Client) ContainerList(ctx context.Context, filters client.Filters) ([]container.Summary, error)
ContainerList lists containers, stopped ones included.
func (*Client) ContainerStart ¶
func (*Client) ContainerWait ¶
ContainerWait waits until the container stops and returns its exit code.
func (*Client) ImageEnsure ¶
ImageEnsure pulls the image, with the encoded credentials of its registry, unless it is on the daemon and the pull policy lets it be used as is.
func (*Client) ImageInspect ¶
func (docker *Client) ImageInspect(ctx context.Context, image string) (image.InspectResponse, error)
ImageInspect describes an image the daemon has.
func (*Client) NetworkCreate ¶
func (docker *Client) NetworkCreate(ctx context.Context, spec NetworkSpec) error
func (*Client) NetworkDelete ¶
func (*Client) NetworkFind ¶
NetworkFind returns the network of that exact name, or nil.
func (*Client) VolumeCreate ¶
func (*Client) VolumeDelete ¶
VolumeDelete removes the volume, and its data.
func (*Client) VolumeFind ¶
VolumeFind returns the volume of that name, or nil.
func (*Client) VolumeProvision ¶
func (docker *Client) VolumeProvision(ctx context.Context, image, registryAuth string, provision target.VolumeProvision) error
VolumeProvision creates the directory of a volume in the storage that provision.Volume mounts: a temporary volume of that storage is mounted in a container of the installer's own image, which creates the directory.
type NetworkSpec ¶
type NetworkSpec struct {
Name string
Options client.NetworkCreateOptions
}
NetworkSpec is a network to create: its name and its options, as both orchestrators convert a compose network.