{"modulePath":"github.com/docker/CLI","version":"v29.10.1+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pruner\n\nPackage pruner registers \"prune\" functions to be included as part of \"docker system prune\".\n\n## Functions\n\n```go\nfunc List() iter.Seq2[ContentType, PruneFunc]\n```\nList iterates over all registered pruners, starting with known pruners in their predefined order, followed by any others (sorted alphabetically).\n\n```go\nfunc Register(name ContentType, pruneFunc PruneFunc) error\n```\nRegister registers a [PruneFunc](#PruneFunc) under the given name to be included in \"docker system prune\". It is designed to be called in an init function and is not safe for concurrent use.\n\nFor example:\n\n\t func init() {\n\t\t// Register the prune command to run as part of \"docker system prune\".\n\t\tif err := prune.Register(prune.TypeImage, prunerFn); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n## Types\n\n```go\ntype ContentType string\n```\nContentType is an identifier for content that can be pruned.\n\n```go\nconst (\n\tTypeContainer  ContentType = \"container\"\n\tTypeNetwork    ContentType = \"network\"\n\tTypeImage      ContentType = \"image\"\n\tTypeVolume     ContentType = \"volume\"\n\tTypeBuildCache ContentType = \"buildcache\"\n)\n```\nPre-defined content-types to prune. Additional types can be registered, and will be pruned after the list of pre-defined types.\n\n```go\ntype PruneFunc func(ctx context.Context, dockerCLI command.Cli, pruneOpts PruneOptions) (spaceReclaimed uint64, details string, _ error)\n```\nPruneFunc is the signature for prune-functions. The action performed depends on the [PruneOptions.Confirmed](#PruneOptions.Confirmed) field.\n\n  - If [PruneOptions.Confirmed](#PruneOptions.Confirmed) is \"false\", the PruneFunc must be run in \"dry-run\" mode and return a short description of what content will be pruned (for example, \"all stopped containers\") instead of executing the prune. This summary is presented to the user as a confirmation message. It may return a [ErrCancelled](https://pkg.go.dev/github.com/docker/docker@v28.3.3+incompatible/errdefs#ErrCancelled) to indicate the operation was canceled or a [ErrNotImplemented](https://pkg.go.dev/github.com/docker/docker@v28.3.3+incompatible/errdefs#ErrNotImplemented) if the prune function is not implemented for the daemon's API version. Any other error is considered a validation error for the given options (such as a filter that is not supported).\n  - If [PruneOptions.Confirmed](#PruneOptions.Confirmed) is \"true\", the PruneFunc must execute the prune with the given options.\n\nAfter a successful prune the PruneFunc must return details about the content pruned;\n\n  - spaceReclaimed is the amount of data removed (in bytes), if any.\n  - details is arbitrary information about the content pruned to be presented to the user.\n\n```go\ntype PruneOptions struct {\n\t// Confirmed indicates whether pruning was confirmed (or \"forced\")\n\t// by the user. If not set, the PruneFunc must be run in \"dry-run\"\n\t// mode and return a short description of what content will be pruned\n\t// (for example, \"all stopped containers\") instead of executing the\n\t// prune. This summary is presented to the user as a confirmation message.\n\tConfirmed bool\n\tAll       bool // Remove all unused content not just dangling (exact meaning differs per content-type).\n\tFilter    opts.FilterOpt\n}\n```\n\n","path":"github.com/docker/CLI/cli/command/system/pruner","name":"pruner","synopsis":"Package pruner registers \"prune\" functions to be included as part of \"docker system prune\".","isRedistributable":true}
