See Manage Images to delete images.

See Manage Containers to delete containers.

Containers

Remove all stopped containers

docker rm $(docker ps -aq)

Force remove all containers

docker rm -f $(docker ps -aq)

Images

Remove all dangling images

Dangling images are layers no longer tagged or referenced by any container.

docker image prune

Remove all unused images

Unused images are simply those not currently associated with a running or stopped container.

docker rmi $(docker images -q)

Full system prune

Deletes stopped containers, unused networks, dangling images (images without a tag), and build caches.

docker system prune -a --volumes

Add -f to force.

Delete build cache

Deletes all build cache, not just the unused parts, forcing Docker to rebuild every layer from scratch next time.

docker builder prune -a -f