space issue on docker devmapper and CentOS7

Just run these three. No need to remove RUNNING containers.

  1. Cleanup exited processes:

    docker rm $(docker ps -q -f status=exited)
    
  2. Cleanup dangling volumes:

    docker volume rm $(docker volume ls -qf dangling=true)
    
  3. Cleanup dangling images:

    docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
    

You can use:

docker system prune -a -f --volumes

where:

  • -a == removes all unused images
  • -f == force
  • --volumes == prune volumes.

see: https://docs.docker.com/engine/reference/commandline/system_prune/#description

as a side note, I had a lot of issues when I used devicemapper driver on my environment. I used to clean as I mentioned, but there were still other devicemapper issues. I strongly recommend moving to overlay2, it solved almost everything completely.