docker

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	KindContainer  = "container"
	KindImage      = "image"
	KindVolume     = "volume"
	KindBuildCache = "build-cache"
)

Kinds of resources a cleanup can touch.

View Source
const (
	ResultSuccess = "success"
	ResultFailure = "failure"
	ResultSkipped = "skipped"
)

Result values of an applied item.

Variables

This section is empty.

Functions

func AuditPath added in v1.7.2

func AuditPath(kind, name string) string

AuditPath is the audit identifier of an item: docker:<kind>:<name>, or docker:build-cache for the cache.

func Digest added in v1.7.2

func Digest(plan CleanupPlan) string

Digest fingerprints a plan: SHA-256 (hex) over its sorted `kind:name` identifiers. Order-independent and stable, so a preview and a later execution can be proven to target the same resources.

func ToDeleteResults added in v1.7.2

func ToDeleteResults(items []ItemResult) []core.DeleteResult

ToDeleteResults adapts item results to the shared audit format.

Types

type BackupResult

type BackupResult struct {
	Path           string `json:"path"`
	SizeBytes      int64  `json:"size_bytes"`
	Container      string `json:"container"`
	Engine         string `json:"engine"`
	User           string `json:"user"`
	DatabasesFound int    `json:"databases_found"`
	TablesFound    int    `json:"tables_found"`
	Verified       bool   `json:"verified"`
	Error          string `json:"error,omitempty"`
}

BackupResult holds the result of a container DB backup

func Backup

func Backup(container string) BackupResult

Backup performs a database backup of a running container

type CleanupPlan added in v1.7.2

type CleanupPlan struct {
	Remove                []PlanItem `json:"remove"`
	Kept                  Kept       `json:"kept"`
	BuildCacheReclaimable string     `json:"build_cache_reclaimable"`
}

CleanupPlan is the read-only description of a cleanup. Apply executes exactly what is in Remove and nothing else.

func Plan added in v1.7.2

func Plan(keep []string) (CleanupPlan, error)

Plan builds the cleanup plan using the real docker CLI. Read-only.

func PlanWith added in v1.7.2

func PlanWith(r Runner, keep []string) (CleanupPlan, error)

PlanWith is Plan with an injectable Runner. It only issues read commands (ps, inspect, images, volume ls, system df); nothing is ever removed here.

func (CleanupPlan) Names added in v1.7.2

func (p CleanupPlan) Names(kind string) []string

Names returns the plan's item names of one kind, in plan order.

type CompactResult

type CompactResult struct {
	RawSize          int64  `json:"raw_size_bytes"`
	RawSizeHuman     string `json:"raw_size"`
	ActualUsed       int64  `json:"actual_used_bytes"`
	ActualUsedHuman  string `json:"actual_used"`
	RecommendedLimit int64  `json:"recommended_limit_bytes"`
	RecommendedHuman string `json:"recommended_limit"`
	Instructions     string `json:"instructions"`
	Error            string `json:"error,omitempty"`
}

CompactResult holds Docker disk compaction analysis

func Compact

func Compact() CompactResult

Compact analyzes Docker.raw vs actual usage and recommends a new disk limit

type ContainerInfo

type ContainerInfo struct {
	Name    string
	Image   string
	Status  string
	Volumes []string
	Env     map[string]string
}

ContainerInfo holds parsed container metadata

type ExecRunner added in v1.7.2

type ExecRunner struct{}

ExecRunner is the production Runner backed by exec.Command (never a shell).

func (ExecRunner) Run added in v1.7.2

func (ExecRunner) Run(args ...string) ([]byte, error)

Run implements Runner.

type ItemResult added in v1.7.2

type ItemResult struct {
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	Result    string `json:"result"`
	Error     string `json:"error,omitempty"`
	SizeBytes int64  `json:"size_bytes,omitempty"`
}

ItemResult is the outcome of applying one PlanItem.

func Apply added in v1.7.2

func Apply(plan CleanupPlan, r Runner) []ItemResult

Apply executes exactly the items in plan through r and reports one result per item. Failures are returned, never swallowed, and one failure does not stop the remaining items.

type Kept added in v1.7.2

type Kept struct {
	Containers []string `json:"containers"`
	Images     []string `json:"images"`
	Volumes    []string `json:"volumes"`
}

Kept lists what the plan preserves: the --keep containers plus the images and volumes they depend on.

type PlanItem added in v1.7.2

type PlanItem struct {
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	SizeBytes int64  `json:"size_bytes,omitempty"`
}

PlanItem is one resource scheduled for removal.

type Runner added in v1.7.2

type Runner interface {
	// Run executes `docker <args...>` and returns its stdout. On failure the
	// error carries the trimmed stderr so callers can surface the real cause.
	Run(args ...string) ([]byte, error)
}

Runner executes a docker CLI command. It is an interface so tests can verify exactly which commands are issued without touching a real daemon.

Jump to

Keyboard shortcuts

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