Skip to content

Latest commit

 

History

History
89 lines (62 loc) · 1.95 KB

README.md

File metadata and controls

89 lines (62 loc) · 1.95 KB

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'