5

A non-root user has been experimenting with running podman and buildah commands but would now just want to reset everything to as it was before starting the experiment (i.e. all container images and containers should be deleted together with the buildah and podman configuration).

My best guess is running

testuser@linux:~$ rm -rf  ~/.local/share/containers/

might work.

What commands do you recommend for this?

Software versions used

Ubuntu 18.04.2 with https://launchpad.net/~projectatomic/+archive/ubuntu/ppa

testuser@linux:~$ dpkg -l|grep podm
ii  podman                                     1.3.2-1~dev~ubuntu18.04~ppa15                amd64        Manage pods, containers and container images.
testuser@linux:~$ dpkg -l|grep buildah
ii  buildah                                    1.9.0-1~dev~ubuntu18.04~ppa17                amd64        A command line tool used for creating OCI images.
testuser@linux:~$
Erik Sjölund
  • 10,690
  • 7
  • 46
  • 74

3 Answers3

8

I have been thinking about adding a command to do this.

podman system reset

Or something like that.

But if nothing has been modified

$ rm -rf  ~/.local/share/containers/ ~/.config/containers

Should get you want you want.

tgogos
  • 23,218
  • 20
  • 96
  • 128
rhatdan
  • 392
  • 1
  • 1
  • The command `rm -rf ~/.local/share/containers/ ~/.config/containers` gave some _Permission denied_ errors. But `buildah unshare rm -rf ~/.local/share/containers/ ~/.config/containers` worked. Would you recommend that command instead? – Erik Sjölund Jun 13 '19 at 09:07
  • 1
    The command `podman system reset` is now available. Could you update your answer to reflect the new situation? – Erik Sjölund Jul 26 '20 at 11:14
3

I would not do it by deleting the storage they way you are because you are assuming there is nothing stored elsewhere under the mount point of the image or container. If you want to clean up EVERYTHING I would do this:

podman rmi -f $(podman images -a -q)

and then

buildah rm -a
Bryon
  • 939
  • 13
  • 25
3

The Red Hat OpenShift training labs recommend these commands to stop and clear cached images:

podman stop --all   # stop all running containers
podman rmi --all    # remove all defined containers, state data and locally cached images
kgibm
  • 852
  • 10
  • 22
John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • For what it's worth, even this didn't delete the overlay folders for me. I ended up `rm -rf`ing everything under `.local/share/containers/storage/overlay` – Ross Presser Feb 15 '22 at 15:31