diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-06-30 05:33:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-30 05:33:21 -0400 |
commit | 78a3605018038d26a9e8868b6ed6ab01146be423 (patch) | |
tree | 253d9db10a45dbcb1baedd94715e93a8bdea27c8 /cmd/podman | |
parent | 0d8d805a76762276c62bd7260a39eb26e99722b4 (diff) | |
parent | 2243b6020330ea06abdb594db9c6c8ff429cfc5d (diff) | |
download | podman-78a3605018038d26a9e8868b6ed6ab01146be423.tar.gz podman-78a3605018038d26a9e8868b6ed6ab01146be423.tar.bz2 podman-78a3605018038d26a9e8868b6ed6ab01146be423.zip |
Merge pull request #10789 from flouthoc/system-reset-prune-external
reset: remove external containers on podman system reset
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/system/reset.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cmd/podman/system/reset.go b/cmd/podman/system/reset.go index 0edb36889..c64d09ed2 100644 --- a/cmd/podman/system/reset.go +++ b/cmd/podman/system/reset.go @@ -45,16 +45,29 @@ func init() { } func reset(cmd *cobra.Command, args []string) { + // Get all the external containers in use + listCtn, _ := registry.ContainerEngine().ContainerListExternal(registry.Context()) + listCtnIds := make([]string, 0, len(listCtn)) + for _, externalCtn := range listCtn { + listCtnIds = append(listCtnIds, externalCtn.ID) + } // Prompt for confirmation if --force is not set if !forceFlag { reader := bufio.NewReader(os.Stdin) - fmt.Print(` + fmt.Println(` WARNING! This will remove: - all containers - all pods - all images - - all build cache -Are you sure you want to continue? [y/N] `) + - all build cache`) + if len(listCtn) > 0 { + fmt.Println(`WARNING! The following external containers will be purged:`) + // print first 12 characters of ID and first configured name alias + for _, externalCtn := range listCtn { + fmt.Printf(" - %s (%s)\n", externalCtn.ID[0:12], externalCtn.Names[0]) + } + } + fmt.Print(`Are you sure you want to continue? [y/N] `) answer, err := reader.ReadString('\n') if err != nil { logrus.Error(err) @@ -65,6 +78,8 @@ Are you sure you want to continue? [y/N] `) } } + // Purge all the external containers with storage + registry.ContainerEngine().ContainerRm(registry.Context(), listCtnIds, entities.RmOptions{Force: true, All: true, Ignore: true, Volumes: true}) // Shutdown all running engines, `reset` will hijack repository registry.ContainerEngine().Shutdown(registry.Context()) registry.ImageEngine().Shutdown(registry.Context()) |