Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FNGarvin/b725dc4f1e345964136140b832dd39f5 to your computer and use it in GitHub Desktop.
Save FNGarvin/b725dc4f1e345964136140b832dd39f5 to your computer and use it in GitHub Desktop.

General guidance for managing WSL space:

  • Use ncdu -x to get an overview for disk usage.
  • Use podman system df to get an overview for prune savings.
  • Delete old, tagged, unwanted images from podman image list w/ podman rmi [imagename].
  • Do a podman ps -a and ensure every container to keep features the to-keep label mnemonic for filtering. Workflow to add it follows:

Workflow to add -to-keep label:

  1. Commit the [stopped] container
    podman commit container_name container_name-tokeep
  2. Rename the existing container so we can use existing --name and test before deleting
    podman rename container_name container_name_old
  3. Use inspect to get previous run/create parameters for duplication
    podman inspect --format '{{range .Config.CreateCommand}}{{.}} {{end}}' container_name_old
  4. Create or run the NEW '-tokeep' image
    podman create --label to-keep=true [(bind,port,env,--name,etc args from the previous command)] container_name-tokeep /bin/whatever
  5. Test
    podman start container_name -ai (or whatever)
  6. Delete backup
    podman rm container_name_old

Finally:

  • Prune [stopped] containers without our "to-keep" label
    podman container prune --filter "label!=to-keep=true"
  • Prune "dangling" images (basically, anything w/o a label)
    podman image prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment