Help us shape the future of Go! Take the 2026 Go Developer Survey

container

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: BSD-3-Clause Imports: 64 Imported by: 0

Documentation

Overview

Package container owns Docker container lifecycle, inspection, listing and stats, plus the HTTP surface that exposes them.

Index

Constants

View Source
const ResourceSampleLimit = 500

ResourceSampleLimit caps how many requested containers one SampleResources call reads.

Variables

This section is empty.

Functions

func FilterExcludedContainers added in v2.11.0

func FilterExcludedContainers(containers []container.Summary, includeInternal, includeHidden bool) []container.Summary

FilterExcludedContainers removes internal and hidden containers unless their corresponding inclusion flags are enabled.

func RegisterContainers

func RegisterContainers(
	api huma.API,
	containerSvc *ContainerService,
	dockerSvc *docker.DockerClientService,
	settingsSvc *settings.SettingsService,
	activitySvc *activity.ActivityService,
	appCtx handlerutil.ActivityAppContext,
)

Types

type CommitContainerInput

type CommitContainerInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
	Body          container.CommitRequest
}

type ContainerActionInput

type ContainerActionInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
}

type ContainerHandler

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

func (*ContainerHandler) CommitContainer

func (*ContainerHandler) CreateContainer

func (*ContainerHandler) DeleteContainer

func (*ContainerHandler) DownloadContainerLogs added in v2.12.0

func (h *ContainerHandler) DownloadContainerLogs(ctx context.Context, input *GetContainerInput) (*huma.StreamResponse, error)

func (*ContainerHandler) EditContainer added in v2.9.0

func (*ContainerHandler) GenerateCompose added in v2.10.0

func (*ContainerHandler) GetContainer

func (*ContainerHandler) GetContainerEditConfig added in v2.9.0

func (*ContainerHandler) GetContainerProcesses added in v2.14.0

func (h *ContainerHandler) GetContainerProcesses(ctx context.Context, input *GetContainerInput) (*handlerutil.Out[container.Processes], error)

func (*ContainerHandler) GetContainerStatusCounts

func (*ContainerHandler) KillContainer

func (*ContainerHandler) ListContainers

func (*ContainerHandler) PauseContainer

func (*ContainerHandler) RedeployContainer

func (*ContainerHandler) RestartContainer

func (*ContainerHandler) SetAutoUpdate

func (*ContainerHandler) StartContainer

func (*ContainerHandler) StopContainer

func (*ContainerHandler) UnpauseContainer

type ContainerListResult

type ContainerListResult struct {
	Items      []containertypes.Summary
	Groups     []containertypes.SummaryGroup
	Pagination pagination.Response
	Counts     containertypes.StatusCounts
}

type ContainerPaginatedResponse

type ContainerPaginatedResponse struct {
	Success               bool                      `json:"success"`
	Data                  []container.Summary       `json:"data"`
	Groups                []container.SummaryGroup  `json:"groups,omitempty"`
	Counts                container.StatusCounts    `json:"counts"`
	Pagination            base.PaginationResponse   `json:"pagination"`
	ResourceSortSupported bool                      `json:"resourceSortSupported"`
	FailedEnvironments    []base.EnvironmentFailure `json:"failedEnvironments,omitempty" doc:"Environments whose results are missing from a multi-environment response"`
}

ContainerPaginatedResponse is the paginated list response for containers.

type ContainerService

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

func NewContainerService

func NewContainerService(
	eventService *event.EventService,
	dockerService *dockerInternal.DockerClientService,
	imageService *image.ImageService,
	settingsService *settings.SettingsService,
	projectService *project.ProjectService,
	kvService *kv.KVService,
	podmanService *podman.Service,
) *ContainerService

func (*ContainerService) AggregateContainers added in v2.16.1

func (s *ContainerService) AggregateContainers(ctx context.Context, params pagination.QueryParams, groupBy string) (ContainerPaginatedResponse, error)

func (*ContainerService) ApplySummaryIcons

func (s *ContainerService) ApplySummaryIcons(ctx context.Context, summaries []containertypes.Summary, metadataByProject map[string]projects.ArcaneComposeMetadata)

ApplySummaryIcons resolves icons for a page of summaries. Icon resolution is deferred until after pagination so the cost is bounded by page size rather than the full container list.

func (*ContainerService) AttachExec

func (s *ContainerService) AttachExec(ctx context.Context, containerID, execID string) (*ExecSession, error)

AttachExec attaches to an exec instance and returns an ExecSession for lifecycle management.

func (*ContainerService) BuildSummaries

func (s *ContainerService) BuildSummaries(
	ctx context.Context,
	containers []container.Summary,
	updateInfoMap map[string]*imagetypes.UpdateInfo,
	currentContainerID string,
	currentContainerErr error,
) []containertypes.Summary

func (*ContainerService) CalculateStatusCounts

func (s *ContainerService) CalculateStatusCounts(items []containertypes.Summary) containertypes.StatusCounts

func (*ContainerService) CommitContainer

CommitContainer creates an image from a container's current filesystem.

func (*ContainerService) CreateContainer

func (s *ContainerService) CreateContainer(
	ctx context.Context,
	config *container.Config,
	hostConfig *container.HostConfig,
	networkingConfig *network.NetworkingConfig,
	containerName string,
	user usertypes.Actor,
	credentials []containerregistry.Credential,
) (
	*container.InspectResponse,
	error,
)

func (*ContainerService) CreateExec

func (s *ContainerService) CreateExec(ctx context.Context, containerID string, cmd []string, cols, rows uint) (string, error)

CreateExec creates an exec instance in the container

func (*ContainerService) DeleteContainer

func (s *ContainerService) DeleteContainer(ctx context.Context, containerID string, force, removeVolumes bool, user usertypes.Actor) error

func (*ContainerService) DownloadLogs added in v2.12.0

func (s *ContainerService) DownloadLogs(ctx context.Context, containerID string) (io.ReadCloser, string, error)

DownloadLogs returns every log line Docker retains for the container as a single plain-text stream plus the attachment filename. Callers must Close it.

func (*ContainerService) EditContainer added in v2.9.0

func (s *ContainerService) EditContainer(ctx context.Context, containerID string, req containertypes.Edit, user usertypes.Actor) (string, error)

EditContainer applies a user-supplied config diff onto the container's inspected config and recreates it. Sections not owned by the edit form are preserved from the existing container.

func (*ContainerService) GetContainerByID

func (s *ContainerService) GetContainerByID(ctx context.Context, id string) (*container.InspectResponse, error)

func (*ContainerService) GetContainerByReference

func (s *ContainerService) GetContainerByReference(ctx context.Context, ref string) (*container.InspectResponse, error)

func (*ContainerService) GetContainerDetails

func (s *ContainerService) GetContainerDetails(ctx context.Context, id string) (containertypes.Details, error)

func (*ContainerService) GetContainerEditConfig added in v2.9.0

func (s *ContainerService) GetContainerEditConfig(ctx context.Context, containerID string) (containertypes.EditConfig, error)

GetContainerEditConfig returns the purpose-built DTO backing the container edit form.

func (*ContainerService) GetContainerNameByID

func (s *ContainerService) GetContainerNameByID(ctx context.Context, id string) (string, error)

GetContainerNameByID resolves a container's clean name from its Docker ID.

func (*ContainerService) GetContainerNameByReference

func (s *ContainerService) GetContainerNameByReference(ctx context.Context, ref string) (string, error)

GetContainerNameByReference resolves a container's clean name from a Docker ID or name.

func (*ContainerService) GetContainerProcesses added in v2.14.0

func (s *ContainerService) GetContainerProcesses(ctx context.Context, containerID string) (containertypes.Processes, error)

GetContainerProcesses returns Docker's `top` snapshot for a container.

func (*ContainerService) KillContainer

func (s *ContainerService) KillContainer(ctx context.Context, containerID, signal string, user usertypes.Actor) error

KillContainer sends a signal to the container's main process (default SIGKILL when signal is empty) without removing the container.

func (*ContainerService) ListContainersPaginated

func (s *ContainerService) ListContainersPaginated(
	ctx context.Context,
	params pagination.QueryParams,
	includeAll bool,
	includeInternal bool,
	includeHidden bool,
	groupBy string,
) (ContainerListResult, error)

func (*ContainerService) PauseContainer

func (s *ContainerService) PauseContainer(ctx context.Context, containerID string, user usertypes.Actor) error

PauseContainer suspends all processes in the container.

func (*ContainerService) RecoverInterruptedRedeploys added in v2.17.0

func (s *ContainerService) RecoverInterruptedRedeploys(ctx context.Context) error

RecoverInterruptedRedeploys resolves journaled redeploy backups a restart left behind: a backup whose replacement is running is removed, and a backup with no replacement gets its original name back but stays stopped.

func (*ContainerService) RedeployContainer

func (s *ContainerService) RedeployContainer(ctx context.Context, containerID string, user usertypes.Actor) (string, error)

func (*ContainerService) ResizeExec added in v2.17.0

func (s *ContainerService) ResizeExec(ctx context.Context, execID string, cols, rows uint) error

func (*ContainerService) RestartContainer

func (s *ContainerService) RestartContainer(ctx context.Context, containerID string, user usertypes.Actor) error

func (*ContainerService) SampleResources added in v2.16.1

func (s *ContainerService) SampleResources(ctx context.Context, ids []string, maxAge time.Duration) (map[string]*containertypes.ResourceSample, error)

SampleResources samples the running containers among the first ResourceSampleLimit ids, refetching samples older than maxAge. Blank, stopped and unknown IDs are omitted.

func (*ContainerService) StartContainer

func (s *ContainerService) StartContainer(ctx context.Context, containerID string, user usertypes.Actor) error

func (*ContainerService) StopContainer

func (s *ContainerService) StopContainer(ctx context.Context, containerID string, user usertypes.Actor) error

func (*ContainerService) StreamLogs

func (s *ContainerService) StreamLogs(ctx context.Context, containerID string, logsChan chan<- string, follow bool, tail, since string, timestamps bool) error

func (*ContainerService) StreamStats

func (s *ContainerService) StreamStats(ctx context.Context, containerID string, statsChan chan<- any) error

func (*ContainerService) UnpauseContainer

func (s *ContainerService) UnpauseContainer(ctx context.Context, containerID string, user usertypes.Actor) error

UnpauseContainer resumes a previously paused container.

type CreateContainerInput

type CreateContainerInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Body          container.Create
}

type DeleteContainerInput

type DeleteContainerInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
	Force         bool   `query:"force" default:"false" doc:"Force delete running container"`
	RemoveVolumes bool   `query:"volumes" default:"false" doc:"Remove associated volumes"`
}

type EditContainerInput added in v2.9.0

type EditContainerInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
	Body          container.Edit
}

type ExecSession

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

func (*ExecSession) Close

func (e *ExecSession) Close(ctx context.Context) error

Close terminates the exec session and kills the process if still running.

func (*ExecSession) Stdin

func (e *ExecSession) Stdin() io.WriteCloser

func (*ExecSession) Stdout

func (e *ExecSession) Stdout() io.Reader

type GenerateComposeInput added in v2.10.0

type GenerateComposeInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Body          container.GenerateComposeRequest
}

type GetContainerEditConfigInput added in v2.9.0

type GetContainerEditConfigInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
}

type GetContainerInput

type GetContainerInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
}

type GetContainerStatusCountsInput

type GetContainerStatusCountsInput struct {
	EnvironmentID   string `path:"id" doc:"Environment ID"`
	IncludeInternal bool   `query:"includeInternal" default:"false" doc:"Include internal containers"`
	IncludeHidden   bool   `query:"includeHidden" default:"false" doc:"Include hidden containers"`
}

type KillContainerInput

type KillContainerInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
	Signal        string `query:"signal" doc:"Signal to send (for example SIGTERM, SIGKILL). Defaults to SIGKILL."`
}

KillContainerInput carries the optional signal for a container kill.

type ListContainersInput

type ListContainersInput struct {
	EnvironmentID   string `path:"id" doc:"Environment ID"`
	Search          string `query:"search" doc:"Search query"`
	Sort            string `query:"sort" doc:"Column to sort by"`
	Order           string `query:"order" default:"asc" doc:"Sort direction"`
	Start           int    `query:"start" default:"0" doc:"Start index"`
	Limit           int    `query:"limit" default:"20" doc:"Limit"`
	GroupBy         string `query:"groupBy" doc:"Optional grouping mode (for example: project)"`
	IncludeInternal bool   `query:"includeInternal" default:"false" doc:"Include internal containers"`
	IncludeHidden   bool   `query:"includeHidden" default:"false" doc:"Include hidden containers"`
	Updates         string `query:"updates" doc:"Filter by update status (has_update, up_to_date, error, unknown)"`
	Standalone      string `query:"standalone" doc:"Filter standalone containers only (true/false)"`
	Label           string `query:"label" doc:"Filter by label key or key=value"`
}

type ListContainersOutput

type ListContainersOutput struct {
	Body ContainerPaginatedResponse
}

type Module

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

Module wires the container domain and mounts its routes.

func New

func New(service *ContainerService, dockerService *docker.DockerClientService, settingsService *settings.SettingsService, activityService *activity.ActivityService) *Module

New wires container routes around an existing service and registers per-container resource metrics once.

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext)

RegisterRoutes mounts the container endpoints. A nil module still registers, so OpenAPI spec generation can discover the routes without a service graph.

func (*Module) Service

func (m *Module) Service() *ContainerService

Service exposes the container service to collaborators.

type RedeployJournal added in v2.17.0

type RedeployJournal struct {
	OriginalID   string    `json:"originalId"`
	OriginalName string    `json:"originalName"`
	BackupName   string    `json:"backupName"`
	NewName      string    `json:"newName"`
	StartedAt    time.Time `json:"startedAt"`
}

RedeployJournal records a container Arcane renamed to a backup name, so recovery only touches its own backups.

type SetAutoUpdateInput

type SetAutoUpdateInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ContainerID   string `path:"containerId" doc:"Container ID"`
	Body          container.SetAutoUpdateRequest
}

SetAutoUpdateInput is the request input for toggling container auto-update.

Directories

Path Synopsis
children
stats
Package stats owns container resource sampling, resource metrics, resource sorting and the live stats stream.
Package stats owns container resource sampling, resource metrics, resource sorting and the live stats stream.

Jump to

Keyboard shortcuts

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