summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorflouthoc <flouthoc.git@gmail.com>2021-06-26 18:55:08 +0530
committerflouthoc <flouthoc.git@gmail.com>2021-06-30 09:04:08 +0530
commit2243b6020330ea06abdb594db9c6c8ff429cfc5d (patch)
treed868bbae55668546b5ab579a92a1308208db2e83 /cmd/podman
parent0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b (diff)
downloadpodman-2243b6020330ea06abdb594db9c6c8ff429cfc5d.tar.gz
podman-2243b6020330ea06abdb594db9c6c8ff429cfc5d.tar.bz2
podman-2243b6020330ea06abdb594db9c6c8ff429cfc5d.zip
reset: remove external containers on podman system reset
[NO TESTS NEEDED] Signed-off-by: flouthoc <flouthoc.git@gmail.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/system/reset.go21
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())