dockerengine

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package dockerengine is the shared runtime for Docker-API protocols. The docker, swarm, and podman plugins all talk to a Docker-compatible daemon over the moby client, so the session, streaming channels, row mapping, pagination, and generic route handlers live here once. Each plugin supplies only its manifest and the route wiring (IDs, permissions, paths).

Index

Constants

View Source
const ComposeProjectLabel = "com.docker.compose.project"

ComposeProjectLabel groups containers/volumes into a Compose project.

View Source
const OverviewKind = "overview"

OverviewKind is the singleton resource kind backing an engine overview dashboard. Each engine plugin declares it in its own manifest.

Variables

This section is empty.

Functions

func BuildImage

func BuildImage(rc *plugin.RequestContext) (any, error)

BuildImage builds an image from an inline Dockerfile, tagging the result.

func ComposeContainers

func ComposeContainers(rc *plugin.RequestContext) (any, error)

func ComposeDown

func ComposeDown(rc *plugin.RequestContext) (any, error)

ComposeDown stops and removes every container belonging to a Compose project.

func ComposeOverview

func ComposeOverview(rc *plugin.RequestContext) (any, error)

func ComposeServices

func ComposeServices(rc *plugin.RequestContext) (any, error)

func ComposeUp

func ComposeUp(rc *plugin.RequestContext) (any, error)

ComposeUp starts every container belonging to a Compose project. The daemon has no Compose engine, so this orchestrates over the project's existing (label-derived) containers rather than reading a Compose file.

func Connect

func Connect(ctx context.Context, cfg plugin.ConnectConfig, defaultSocket string) (plugin.Session, error)

Connect dials the daemon for cfg's transport. defaultSocket is the unix socket used when none is configured (e.g. /var/run/docker.sock, /run/podman/podman.sock).

func ConnectNetwork

func ConnectNetwork(rc *plugin.RequestContext) (any, error)

func ContainerEnv

func ContainerEnv(rc *plugin.RequestContext) (any, error)

func ContainerOverview

func ContainerOverview(rc *plugin.RequestContext) (any, error)

func ContainerProxyURL

func ContainerProxyURL(rc *plugin.RequestContext) (any, error)

ContainerProxyURL returns the gateway URL that proxies to a container's web port for an "Open in browser" link, picking a likely web port when none given.

func CreateContainer

func CreateContainer(rc *plugin.RequestContext) (any, error)

func CreateContainerSchema

func CreateContainerSchema() *plugin.Schema

func CreateNetwork

func CreateNetwork(rc *plugin.RequestContext) (any, error)

func CreateVolume

func CreateVolume(rc *plugin.RequestContext) (any, error)

func DisconnectNetwork

func DisconnectNetwork(rc *plugin.RequestContext) (any, error)

func DockerErr

func DockerErr(err error) error

DockerErr maps a moby client error to a platform sentinel so the response layer can pick the right status code.

func ExecSchema

func ExecSchema() *plugin.Schema

func ExecStream

func ExecStream(rc *plugin.RequestContext, client plugin.ClientStream) error

func ImageBuildSchema

func ImageBuildSchema() *plugin.Schema

func ImageOverview

func ImageOverview(rc *plugin.RequestContext) (any, error)

func ImagePullSchema

func ImagePullSchema() *plugin.Schema

func ImagePushSchema

func ImagePushSchema() *plugin.Schema

func ImageTagSchema

func ImageTagSchema() *plugin.Schema

func InspectContainer

func InspectContainer(rc *plugin.RequestContext) (any, error)

func InspectImage

func InspectImage(rc *plugin.RequestContext) (any, error)

func InspectNetwork

func InspectNetwork(rc *plugin.RequestContext) (any, error)

func InspectVolume

func InspectVolume(rc *plugin.RequestContext) (any, error)

func KillContainer

func KillContainer(rc *plugin.RequestContext) (any, error)

KillContainer sends a signal to a container, defaulting to SIGKILL.

func KillContainerSchema

func KillContainerSchema() *plugin.Schema

func ListCompose

func ListCompose(rc *plugin.RequestContext) (any, error)

func ListContainers

func ListContainers(rc *plugin.RequestContext) (any, error)

func ListImages

func ListImages(rc *plugin.RequestContext) (any, error)

func ListNetworks

func ListNetworks(rc *plugin.RequestContext) (any, error)

func ListVolumes

func ListVolumes(rc *plugin.RequestContext) (any, error)

func LogsSchema

func LogsSchema() *plugin.Schema

func LogsStream

func LogsStream(rc *plugin.RequestContext, client plugin.ClientStream) error

func MetricsLoop

func MetricsLoop(rc *plugin.RequestContext, stream plugin.ClientStream, frame func(context.Context) map[string]any) error

MetricsLoop streams frames on a fixed cadence until the client or request context closes. A frame builder that can't reach its data returns what it has.

func NetworkConnectSchema

func NetworkConnectSchema() *plugin.Schema

func NetworkCreateSchema

func NetworkCreateSchema() *plugin.Schema

func NetworkDisconnectSchema

func NetworkDisconnectSchema() *plugin.Schema

func NetworkOverview

func NetworkOverview(rc *plugin.RequestContext) (any, error)

func OverviewList

func OverviewList(_ *plugin.RequestContext) (any, error)

OverviewList is the single row backing the overview ResourceType.

func OverviewMetrics

func OverviewMetrics(rc *plugin.RequestContext, stream plugin.ClientStream) error

OverviewMetrics streams live counts of the engine's containers, images, volumes, and networks.

func OverviewMetricsConfig

func OverviewMetricsConfig() plugin.MetricsConfig

OverviewMetricsConfig declares the environment count tiles.

func OverviewRef

func OverviewRef() *plugin.ResourceRef

OverviewRef opens the overview dashboard from a tree group.

func PageRows

func PageRows(rc *plugin.RequestContext, rows []Row) (plugin.Page[Row], error)

PageRows applies the request's filter, sort, and cursor pagination to rows.

func PauseContainer

func PauseContainer(rc *plugin.RequestContext) (any, error)

func PruneContainers

func PruneContainers(rc *plugin.RequestContext) (any, error)

PruneContainers removes all stopped containers.

func PruneImages

func PruneImages(rc *plugin.RequestContext) (any, error)

PruneImages removes dangling images.

func PruneNetworks

func PruneNetworks(rc *plugin.RequestContext) (any, error)

PruneNetworks removes unused networks.

func PruneVolumes

func PruneVolumes(rc *plugin.RequestContext) (any, error)

PruneVolumes removes unused volumes.

func PullImage

func PullImage(rc *plugin.RequestContext) (any, error)

PullImage pulls an image by reference, waiting for the pull to finish.

func PushImage

func PushImage(rc *plugin.RequestContext) (any, error)

PushImage pushes an image reference to a registry, optionally authenticating.

func RawOrValue

func RawOrValue(raw json.RawMessage, value any) (any, error)

RawOrValue returns the daemon's raw inspect JSON when present, falling back to the typed value. Plugin packages use it for their own inspect routes.

func RemoveContainer

func RemoveContainer(rc *plugin.RequestContext) (any, error)

func RemoveImage

func RemoveImage(rc *plugin.RequestContext) (any, error)

func RemoveNetwork

func RemoveNetwork(rc *plugin.RequestContext) (any, error)

func RemoveVolume

func RemoveVolume(rc *plugin.RequestContext) (any, error)

func RenameContainer

func RenameContainer(rc *plugin.RequestContext) (any, error)

func RenameContainerSchema

func RenameContainerSchema() *plugin.Schema

func RestartContainer

func RestartContainer(rc *plugin.RequestContext) (any, error)

func ShortID

func ShortID(id string) string

ShortID trims a sha256 prefix and truncates to 12 chars for display.

func StartContainer

func StartContainer(rc *plugin.RequestContext) (any, error)

func StateSeverities

func StateSeverities() map[string]plugin.Severity

StateSeverities colors a container "state" badge by value.

func StopContainer

func StopContainer(rc *plugin.RequestContext) (any, error)

func TagImage

func TagImage(rc *plugin.RequestContext) (any, error)

func TreeCompose

func TreeCompose(rc *plugin.RequestContext) (any, error)

func TreeContainers

func TreeContainers(rc *plugin.RequestContext) (any, error)

func TreeFromRows

func TreeFromRows(rc *plugin.RequestContext, kind string, fn func(*plugin.RequestContext) (any, error)) (any, error)

TreeFromRows turns a list handler's Page[Row] into sidebar tree nodes, using each row's "ref" to build the node. fn is typically one of the List* handlers.

func TreeImages

func TreeImages(rc *plugin.RequestContext) (any, error)

func TreeNetworks

func TreeNetworks(rc *plugin.RequestContext) (any, error)

func TreeVolumes

func TreeVolumes(rc *plugin.RequestContext) (any, error)

func UnpauseContainer

func UnpauseContainer(rc *plugin.RequestContext) (any, error)

func VolumeCreateSchema

func VolumeCreateSchema() *plugin.Schema

func VolumeOverview

func VolumeOverview(rc *plugin.RequestContext) (any, error)

func WatchEvents

func WatchEvents(rc *plugin.RequestContext, client plugin.ClientStream) error

func WhenState

func WhenState(states ...string) *plugin.Condition

WhenState gates an action on the row's "state" field.

Types

type ActionResult

type ActionResult struct {
	OK bool `json:"ok"`
}

type BuildResult

type BuildResult struct {
	OK     bool   `json:"ok"`
	Tag    string `json:"tag"`
	Output string `json:"output,omitempty"`
}

BuildResult carries the collected daemon build log back to the generic toast.

type ComposeResult

type ComposeResult struct {
	OK        bool `json:"ok"`
	Affected  int  `json:"affected"`
	Succeeded int  `json:"succeeded"`
}

ComposeResult summarises how many of a project's containers an op touched.

type CreateContainerRequest

type CreateContainerRequest struct {
	Name           string `json:"name"`
	Image          string `json:"image" validate:"required"`
	Pull           *bool  `json:"pull"`
	Start          *bool  `json:"start"`
	Command        string `json:"command"`
	Entrypoint     string `json:"entrypoint"`
	User           string `json:"user"`
	WorkingDir     string `json:"working_dir"`
	Env            string `json:"env"`
	Ports          string `json:"ports"`
	Binds          string `json:"binds"`
	Network        string `json:"network"`
	Restart        string `json:"restart"`
	RestartRetries int    `json:"restart_retries"`
	TTY            bool   `json:"tty"`
	OpenStdin      bool   `json:"open_stdin"`
}

type CreateContainerResult

type CreateContainerResult struct {
	OK       bool     `json:"ok"`
	ID       string   `json:"id"`
	Name     string   `json:"name,omitempty"`
	Started  bool     `json:"started"`
	Warnings []string `json:"warnings,omitempty"`
}

type PruneResult

type PruneResult struct {
	OK             bool   `json:"ok"`
	Deleted        int    `json:"deleted"`
	SpaceReclaimed uint64 `json:"spaceReclaimed"`
}

PruneResult summarises a prune sweep for the generic action toast.

type Row

type Row = map[string]any

Row is one generic record returned by the shared handlers. It is an alias so plugin packages can build rows as plain maps and still feed PageRows/TreeFromRows.

func ContainerRows

func ContainerRows(items []container.Summary) []Row

func ImageRows

func ImageRows(items []image.Summary) []Row

func NetworkRows

func NetworkRows(items []network.Summary) []Row

func VolumeRows

func VolumeRows(items []volume.Volume) []Row

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is a live connection to one Docker-compatible daemon. It is created per connection and holds all per-connection state; plugins stay stateless.

func Unwrap

func Unwrap(sess plugin.Session) (*Session, error)

Unwrap recovers the engine Session from a plugin.Session, transparently looking through a wrapper (e.g. the recording layer) that exposes Session().

func (*Session) Client

func (s *Session) Client() *dockerclient.Client

Client exposes the moby client so plugin-specific handlers (swarm services, nodes, tasks; podman pods) can issue calls the shared handlers don't cover.

func (*Session) Close

func (s *Session) Close() error

func (*Session) HTTPClient

func (s *Session) HTTPClient() *http.Client

HTTPClient exposes the daemon-dialing HTTP client for Podman's libpod-only endpoints.

func (*Session) HealthCheck

func (s *Session) HealthCheck(ctx context.Context) error

func (*Session) OpenChannel

func (s *Session) OpenChannel(ctx context.Context, req plugin.ChannelRequest) (plugin.Channel, error)

func (*Session) ProxyURL

func (s *Session) ProxyURL(kind, id, port string) string

ProxyURL builds the gateway "open in browser" URL for a target.

func (*Session) ServeHTTPProxy

func (s *Session) ServeHTTPProxy(w http.ResponseWriter, r *http.Request)

ServeHTTPProxy reverse-proxies a browser to a container's or swarm service's web port, via `/{container|service}/{id}/{port}/{rest...}`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL