mirror of
https://github.com/containers/podman.git
synced 2025-12-04 20:28:40 +08:00
Remove containers when pruning a stopped pod.
This path allows pod prune & pod rm to remove stopped containers in the pod before deleting the pod. PrunePods and RemovePod should be able to remove containers without force removal of stopped pods. Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
var (
|
||||
podRmCommand cliconfig.PodRmValues
|
||||
podRmDescription = fmt.Sprintf(`podman rm will remove one or more pods from the host.
|
||||
podRmDescription = fmt.Sprintf(`podman rm will remove one or more stopped pods and their containers from the host.
|
||||
|
||||
The pod name or ID can be used. A pod with containers will not be removed without --force. If --force is specified, all containers will be stopped, then removed.`)
|
||||
_podRmCommand = &cobra.Command{
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
_prunePodsCommand = &cobra.Command{
|
||||
Use: "prune",
|
||||
Args: noSubArgs,
|
||||
Short: "Remove all stopped pods",
|
||||
Short: "Remove all stopped pods and their containers",
|
||||
Long: podPruneDescription,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
podPruneCommand.InputArgs = args
|
||||
@@ -32,7 +32,7 @@ func init() {
|
||||
podPruneCommand.SetHelpTemplate(HelpTemplate())
|
||||
podPruneCommand.SetUsageTemplate(UsageTemplate())
|
||||
flags := podPruneCommand.Flags()
|
||||
flags.BoolVarP(&podPruneCommand.Force, "force", "f", false, "Force removal of a running pods. The default is false")
|
||||
flags.BoolVarP(&podPruneCommand.Force, "force", "f", false, "Force removal of all running pods. The default is false")
|
||||
}
|
||||
|
||||
func podPruneCmd(c *cliconfig.PodPruneValues) error {
|
||||
|
||||
@@ -82,7 +82,6 @@ Are you sure you want to continue? [y/N] `, volumeString)
|
||||
fmt.Println("Deleted Pods")
|
||||
pruneValues := cliconfig.PodPruneValues{
|
||||
PodmanCommand: c.PodmanCommand,
|
||||
Force: c.Force,
|
||||
}
|
||||
ctx := getContext()
|
||||
ok, failures, lasterr := runtime.PrunePods(ctx, &pruneValues)
|
||||
|
||||
Reference in New Issue
Block a user