mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
better prune and system df
Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
parent
2f12d28084
commit
fd62b6c950
8 changed files with 19 additions and 19 deletions
|
@ -542,13 +542,13 @@ type DiskUsage struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImagesPruneConfig contains the configuration for Remote API:
|
// ImagesPruneConfig contains the configuration for Remote API:
|
||||||
// POST "/image/prune"
|
// POST "/images/prune"
|
||||||
type ImagesPruneConfig struct {
|
type ImagesPruneConfig struct {
|
||||||
DanglingOnly bool
|
DanglingOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainersPruneConfig contains the configuration for Remote API:
|
// ContainersPruneConfig contains the configuration for Remote API:
|
||||||
// POST "/image/prune"
|
// POST "/images/prune"
|
||||||
type ContainersPruneConfig struct {
|
type ContainersPruneConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ type VolumesPruneReport struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImagesPruneReport contains the response for Remote API:
|
// ImagesPruneReport contains the response for Remote API:
|
||||||
// POST "/image/prune"
|
// POST "/images/prune"
|
||||||
type ImagesPruneReport struct {
|
type ImagesPruneReport struct {
|
||||||
ImagesDeleted []ImageDelete
|
ImagesDeleted []ImageDelete
|
||||||
SpaceReclaimed uint64
|
SpaceReclaimed uint64
|
||||||
|
|
|
@ -67,7 +67,7 @@ func runPrune(dockerCli *command.DockerCli, opts pruneOptions) (spaceReclaimed u
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPrune call the Container Prune API
|
// RunPrune calls the Container Prune API
|
||||||
// This returns the amount of space reclaimed and a detailed output string
|
// This returns the amount of space reclaimed and a detailed output string
|
||||||
func RunPrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
func RunPrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
||||||
return runPrune(dockerCli, pruneOptions{force: true})
|
return runPrune(dockerCli, pruneOptions{force: true})
|
||||||
|
|
|
@ -83,7 +83,7 @@ func runPrune(dockerCli *command.DockerCli, opts pruneOptions) (spaceReclaimed u
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPrune call the Image Prune API
|
// RunPrune calls the Image Prune API
|
||||||
// This returns the amount of space reclaimed and a detailed output string
|
// This returns the amount of space reclaimed and a detailed output string
|
||||||
func RunPrune(dockerCli *command.DockerCli, all bool) (uint64, string, error) {
|
func RunPrune(dockerCli *command.DockerCli, all bool) (uint64, string, error) {
|
||||||
return runPrune(dockerCli, pruneOptions{force: true, all: all})
|
return runPrune(dockerCli, pruneOptions{force: true, all: all})
|
||||||
|
|
|
@ -8,32 +8,32 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewContainerPruneCommand return a cobra prune command for containers
|
// NewContainerPruneCommand returns a cobra prune command for containers
|
||||||
func NewContainerPruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
func NewContainerPruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
return container.NewPruneCommand(dockerCli)
|
return container.NewPruneCommand(dockerCli)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVolumePruneCommand return a cobra prune command for volumes
|
// NewVolumePruneCommand returns a cobra prune command for volumes
|
||||||
func NewVolumePruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
func NewVolumePruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
return volume.NewPruneCommand(dockerCli)
|
return volume.NewPruneCommand(dockerCli)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImagePruneCommand return a cobra prune command for images
|
// NewImagePruneCommand returns a cobra prune command for images
|
||||||
func NewImagePruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
func NewImagePruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
return image.NewPruneCommand(dockerCli)
|
return image.NewPruneCommand(dockerCli)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunContainerPrune execute a prune command for containers
|
// RunContainerPrune executes a prune command for containers
|
||||||
func RunContainerPrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
func RunContainerPrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
||||||
return container.RunPrune(dockerCli)
|
return container.RunPrune(dockerCli)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunVolumePrune execute a prune command for volumes
|
// RunVolumePrune executes a prune command for volumes
|
||||||
func RunVolumePrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
func RunVolumePrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
||||||
return volume.RunPrune(dockerCli)
|
return volume.RunPrune(dockerCli)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunImagePrune execute a prune command for images
|
// RunImagePrune executes a prune command for images
|
||||||
func RunImagePrune(dockerCli *command.DockerCli, all bool) (uint64, string, error) {
|
func RunImagePrune(dockerCli *command.DockerCli, all bool) (uint64, string, error) {
|
||||||
return image.RunPrune(dockerCli, all)
|
return image.RunPrune(dockerCli, all)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func NewDiskUsageCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "df [OPTIONS]",
|
Use: "df [OPTIONS]",
|
||||||
Short: "Show docker disk usage",
|
Short: "Show docker disk usage",
|
||||||
Args: cli.RequiresMaxArgs(1),
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runDiskUsage(dockerCli, opts)
|
return runDiskUsage(dockerCli, opts)
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,13 +15,13 @@ type pruneOptions struct {
|
||||||
all bool
|
all bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPruneCommand creates a new cobra.Command for `docker du`
|
// NewPruneCommand creates a new cobra.Command for `docker prune`
|
||||||
func NewPruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
func NewPruneCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
var opts pruneOptions
|
var opts pruneOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "prune [OPTIONS]",
|
Use: "prune [OPTIONS]",
|
||||||
Short: "Remove unused data.",
|
Short: "Remove unused data",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runPrune(dockerCli, opts)
|
return runPrune(dockerCli, opts)
|
||||||
|
|
|
@ -67,7 +67,7 @@ func runPrune(dockerCli *command.DockerCli, opts pruneOptions) (spaceReclaimed u
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPrune call the Volume Prune API
|
// RunPrune calls the Volume Prune API
|
||||||
// This returns the amount of space reclaimed and a detailed output string
|
// This returns the amount of space reclaimed and a detailed output string
|
||||||
func RunPrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
func RunPrune(dockerCli *command.DockerCli) (uint64, string, error) {
|
||||||
return runPrune(dockerCli, pruneOptions{force: true})
|
return runPrune(dockerCli, pruneOptions{force: true})
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/docker/docker/volume"
|
"github.com/docker/docker/volume"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainersPrune remove unused containers
|
// ContainersPrune removes unused containers
|
||||||
func (daemon *Daemon) ContainersPrune(config *types.ContainersPruneConfig) (*types.ContainersPruneReport, error) {
|
func (daemon *Daemon) ContainersPrune(config *types.ContainersPruneConfig) (*types.ContainersPruneReport, error) {
|
||||||
rep := &types.ContainersPruneReport{}
|
rep := &types.ContainersPruneReport{}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ func (daemon *Daemon) ContainersPrune(config *types.ContainersPruneConfig) (*typ
|
||||||
// TODO: sets RmLink to true?
|
// TODO: sets RmLink to true?
|
||||||
err := daemon.ContainerRm(c.ID, &types.ContainerRmConfig{})
|
err := daemon.ContainerRm(c.ID, &types.ContainerRmConfig{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warnf("failed to prune container %s: %v", c.ID)
|
logrus.Warnf("failed to prune container %s: %v", c.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cSize > 0 {
|
if cSize > 0 {
|
||||||
|
@ -35,7 +35,7 @@ func (daemon *Daemon) ContainersPrune(config *types.ContainersPruneConfig) (*typ
|
||||||
return rep, nil
|
return rep, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// VolumesPrune remove unused local volumes
|
// VolumesPrune removes unused local volumes
|
||||||
func (daemon *Daemon) VolumesPrune(config *types.VolumesPruneConfig) (*types.VolumesPruneReport, error) {
|
func (daemon *Daemon) VolumesPrune(config *types.VolumesPruneConfig) (*types.VolumesPruneReport, error) {
|
||||||
rep := &types.VolumesPruneReport{}
|
rep := &types.VolumesPruneReport{}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func (daemon *Daemon) VolumesPrune(config *types.VolumesPruneConfig) (*types.Vol
|
||||||
return rep, err
|
return rep, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImagesPrune remove unused images
|
// ImagesPrune removes unused images
|
||||||
func (daemon *Daemon) ImagesPrune(config *types.ImagesPruneConfig) (*types.ImagesPruneReport, error) {
|
func (daemon *Daemon) ImagesPrune(config *types.ImagesPruneConfig) (*types.ImagesPruneReport, error) {
|
||||||
rep := &types.ImagesPruneReport{}
|
rep := &types.ImagesPruneReport{}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue