Documentation
¶
Overview ¶
Package docker is a Docker Engine API implementation of runtime.Runtime.
It uses github.com/moby/moby/client (the canonical post-split SDK path). We chose moby over github.com/docker/docker/client to favor the upstream module that the broader Go container ecosystem is converging on, avoiding two near-duplicate transitive trees when downstream consumers also depend on moby/moby/api.
All methods accept context.Context; streaming endpoints (PullImage, BuildImage, follow logs) are wrapped with runtime.CancellableCopy so ctx cancellation always returns within milliseconds.
Index ¶
- type Options
- type Runtime
- func (r *Runtime) BuildImage(ctx context.Context, spec runtime.BuildSpec, events chan<- runtime.BuildEvent) (runtime.ImageRef, error)
- func (r *Runtime) Close() error
- func (r *Runtime) ComposeContainerID(ctx context.Context, spec runtime.ComposePsSpec, service string) (string, error)
- func (r *Runtime) ComposeDown(ctx context.Context, spec runtime.ComposeDownSpec) error
- func (r *Runtime) ComposeUp(ctx context.Context, spec runtime.ComposeUpSpec, ...) error
- func (r *Runtime) ContainerLogs(ctx context.Context, id string, w io.Writer, follow bool) error
- func (r *Runtime) ExecContainer(ctx context.Context, id string, opts runtime.ExecOptions) (runtime.ExecResult, error)
- func (r *Runtime) FindContainerByLabel(ctx context.Context, key, value string) (*runtime.Container, error)
- func (r *Runtime) InspectContainer(ctx context.Context, id string) (*runtime.ContainerDetails, error)
- func (r *Runtime) InspectImage(ctx context.Context, ref string) (*runtime.ImageDetails, error)
- func (r *Runtime) PullImage(ctx context.Context, ref string, events chan<- runtime.BuildEvent) (runtime.ImageRef, error)
- func (r *Runtime) RemoveContainer(ctx context.Context, id string, opts runtime.RemoveOptions) error
- func (r *Runtime) RunContainer(ctx context.Context, spec runtime.RunSpec) (*runtime.Container, error)
- func (r *Runtime) StartContainer(ctx context.Context, id string) error
- func (r *Runtime) StopContainer(ctx context.Context, id string, opts runtime.StopOptions) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Host overrides DOCKER_HOST (e.g. "unix:///var/run/docker.sock"
// or "tcp://192.168.0.1:2375"). Empty falls back to env.
Host string
}
Options configure New. The zero value is valid: it builds a client that reads DOCKER_HOST/DOCKER_API_VERSION/etc. from the environment and negotiates the API version with the daemon.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the Docker Engine implementation of runtime.Runtime (and runtime.ComposeRuntime).
func New ¶
New constructs a Docker runtime. If the daemon is unreachable the returned error is a *runtime.DaemonUnavailableError.
func (*Runtime) BuildImage ¶
func (r *Runtime) BuildImage(ctx context.Context, spec runtime.BuildSpec, events chan<- runtime.BuildEvent) (runtime.ImageRef, error)
BuildImage builds an image from a build context directory and tags it. Implements runtime.Runtime.BuildImage.
Streaming progress messages are mapped onto the events channel as runtime.BuildEvents (drop-on-full). Build failures surface as a non-nil error including any structured error returned by the daemon.
func (*Runtime) ComposeContainerID ¶
func (r *Runtime) ComposeContainerID(ctx context.Context, spec runtime.ComposePsSpec, service string) (string, error)
ComposeContainerID resolves the container id for a service via `docker compose ps -q <service>`. Returns "" if the service isn't running (compose returns empty stdout, exit 0).
func (*Runtime) ComposeDown ¶
ComposeDown stops and (optionally) cleans the project.
func (*Runtime) ComposeUp ¶
func (r *Runtime) ComposeUp(ctx context.Context, spec runtime.ComposeUpSpec, events chan<- runtime.BuildEvent) error
ComposeUp brings the project up in detached mode.
func (*Runtime) ContainerLogs ¶
func (*Runtime) ExecContainer ¶
func (r *Runtime) ExecContainer(ctx context.Context, id string, opts runtime.ExecOptions) (runtime.ExecResult, error)