Skip to content

Commit

Permalink
[v3.4] system reset: show graphRoot/runRoot before removal
Browse files Browse the repository at this point in the history
Backport of commit 6aaf6a2.

system reset it says it will delete containers, images, networks, etc...
However it will also delete the graphRoot and runRoot directories.
Normally this is not an issue, however in same cases these directories
were set to the users home directory or some other important system
directory.

As first step simply show the directories that are configured and thus
will be deleted by reset. As future step we could implement some
safeguard will will not delete some known important directories however
I tried to keep it simple for now.

[NO NEW TESTS NEEDED]

see containers#18349, containers#18295, and containers#19870

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Sep 6, 2023
1 parent f287c0b commit a34dbdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/podman/system/reset.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !remote
// +build !remote

package system
Expand Down Expand Up @@ -61,6 +62,12 @@ WARNING! This will remove:
- all pods
- all images
- all build cache`)
info, _ := registry.ContainerEngine().Info(registry.Context())
// lets not hard fail in case of an error
if info != nil {
fmt.Printf(" - the graphRoot directory: %q\n", info.Store.GraphRoot)
fmt.Printf(" - the runRoot directory: %q\n", info.Store.RunRoot)
}
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
Expand Down
2 changes: 2 additions & 0 deletions docs/source/markdown/podman-system-reset.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ podman\-system\-reset - Reset storage back to initial state
This command must be run **before** changing any of the following fields in the
`containers.conf` or `storage.conf` files: `driver`, `static_dir`, `tmp_dir`
or `volume_path`.
It also removes the configured graphRoot and runRoot directories. Make sure
these are not set to some important directory.

`podman system reset` reads the current configuration and attempts to remove all
of the relevant configurations. If the administrator modified the configuration files first,
Expand Down

0 comments on commit a34dbdc

Please sign in to comment.