Skip to content

Some bash commands for cleaning up your Docker / Podman environment

License

Notifications You must be signed in to change notification settings

hareldev/docker-cleanup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Docker / Podman cleanup

Check disk space used

In RedHat based OS, docker containers will be kept in ~/.local/share/containers/storage by default.

du -sh ~/.local/share/containers/storage 2> >(grep -v 'Permission denied') | sort -n

Containers

List all containers of specific image

docker ps -a -q --filter ancestor=[containerName]

List stopped containers of specific image

docker ps -a -q --filter "ancestor=[containerName]" --filter "status=exited"

Remove stopped containers of specific image

docker rm $(docker ps -a -q --filter "ancestor=[containerName]" --filter "status=exited")

Images

List dangling images

docker images -q --filter "dangling=true"

List images of specific name / tag

  • notice this is not an exact match
docker images --filter "reference=[imageName]:[imageTag]"

Remove images of any group

docker rmi $(docker images -q [any filter])

System usage

Docker system info

docker system df

Docker system prune - remove unused data

docker system prune

Docker builder cache prune

docker builder prune

Delete unmounted volumes

podman volume rm --all

Docker Troubleshooting

Change image ENTRYPOINT

In case you're getting an error running a container, which might expect environment variable, or run an executalbe, you could debug it by changing the entrypoint:

podman run -d --entrypoint "/bin/bash" [image_ID] -c 'while true; do echo sleeping; sleep 2; done'
If you're getting an error of: Error: unable to find user default: no matching entries in passwd file you'll need to specify the user:
podman run -d --user [username/id] --entrypoint "/bin/bash" [image_ID] -c 'while true; do echo sleeping; sleep 2; done'

About

Some bash commands for cleaning up your Docker / Podman environment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages