I have few issues with storage spaces. I deleted few big files such as log files (after find unix of big files).
The problem is that delete manually some file of Docker (in /var/lib/docker/...). After deletion of Docker files, I can see that the space left does not change. Docker does not release space.
I restart the service Docker and I the problem persit.
How can I force Docker to release space from (devicemapper, volume, images, ...) ?
Docker cleanup job is rather non-existing and you are basically in charge of doing it yourself. There are ways of doing that as pointed out in this blog-post, yet I rather use third-party scripts, e.g.: docker-clean to clean up some of the mess docker leaves behind.
With recent versions of Docker you can see the space used with:
docker system df
and prune it with:
docker system prune
The above command combines the prune command that exists for volumes, containers, networks and images:
docker volume prune
docker container prune
docker image prune
docker network prune
All of these have a --help option
.
-o-
On older versions of Docker I ran the script:
#!/bin/bash
# Remove dead containers (and their volumes)
docker ps -f status=dead --format '{{ .ID }}' | xargs -r docker rm -v
# Remove dangling volumes
docker volume ls -qf dangling=true | xargs -r docker volume rm
# Remove untagged ("<none>") images
docker images --digests --format '{{.Repository}}:{{.Tag}}@{{.Digest}}' | sed -rne 's/([^>]):<none>@/\1@/p' | xargs -r docker rmi
# Remove dangling images
docker images -qf dangling=true | xargs -r docker rmi
# Remove temporary files
rm -f /var/lib/docker/tmp/*
This depends on what version of docker you are using, If you are using >1.13 then you can use:
docker system df
and
docker system df -v
^^These will show where disk space is being utilized.
You can cleanup using prune
commands:
docker system prune -af
^^ This prunes everything & is the most destructive.
Or you can use docker image prune
or docker volume prune
etc.