docker remove cached images code example

Example 1: docker remove all images

docker rmi $(docker images -a -q)

Example 2: docker clear cache

# Rebuild the image
docker build --no-cache

# Pull the base images again and rebuild
docker build --no-cache --pull

# Also works with docker-compose
docker-compose build --no-cache

# If nothing of the above works for you, you could also prune everything
docker system to prune

Example 3: docker remove image

docker image rm [OPTIONS] IMAGE [IMAGE...]
#[OPTIONS]
--force , -f		Force removal of the image
--no-prune		Do not delete untagged parents

Example 4: docker clear cache

docker volume prune