I can see docker disk using the docker system df command:
$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 31 1 12.86GB 12.81GB (99%)
Containers 1 0 0B 0B
Local Volumes 25 1 17.24GB 17.19GB (99%)
Build Cache 244 0 6.249GB 6.249GB
The output shows one image and one volume are active. How can I find these active objects?
I don't think I have any active objects because docker ps displays no results. Perhaps these are internally managed docker objects?
docker ps -a solved the problem
Related
#docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 222 0 42.87GB 42.87GB (100%)
Containers 0 0 0B 0B
Local Volumes 10 0 77.68MB 77.68MB (100%)
Build Cache 946 0 7.982GB 7.982GB
From the docker system df command, it seems my docker disk is running out of space. But Docker desktop shows:
So I am confused which one should be the right one to indicate docker space usage?
If you're on a mac/windows, then it means that behind the scenes you're running a VM running linux. That disk size then corresponds to the VM disk size containing the Linux distro, rather than just the docker stuff.
Actually, the RECLAIMABLE column is basically the size and percentage of the resources that aren't in use, there is no container using these images/volumes. In your case, 100% of the images and volumes are in "Idle" so you can remove them if you want, there are some good ways to remove it like docker image prune and docker system prune.
The image that you sent has what you are looking for.
I have two docker containers running, where the diskspace is as follows:
user$ sudo docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 2 1 448.3MB 1.84kB (0%)
Containers 2 2 284.4MB 0B (0%)
Local Volumes 7 2 418.8kB 176.4kB (42%)
Build Cache 0 0 0B 0B
If I check diskusage I get:
root:/var/lib/docker# du -ah --max-depth=1
45G ./containers
What can I do to keep the containers (since I made a lot of configuration) but remove the obvious overhead?
Please run the below command the clean the system as
This will remove:
all stopped containers
all networks not used by at least one container
all dangling images
all dangling build cache
docker system prune -f
And yes, you can remove the son file as well.
You can use docker system prune -f, but, from my experience, it is not cleaning all that can be cleaned up.
For that, I've created a simple Docker image that does all the needed cleaning using only one command:
docker run -v /var/run/docker.sock:/var/run/docker.sock tikalci/tci-docker-cleanup:latest
For more details, see: https://github.com/TikalCI/tci-docker-cleanup
In the spirit of this question, how does docker determine the 'reclaimability' of disk space used by the images and containers? An example of docker system df (which I have recently pruned):
>> xx:xx:xx > nope > docker >> docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 12 0 14.07GB 14.07GB (100%)
Containers 0 0 0B 0B
Local Volumes 7 0 817.1kB 817.1kB (100%)
Build Cache 0B 0B
Can I use the Dockerfile or docker-compose.yaml to manipulate or control how this designation is applied to disk space? For example, if I wanted to continually clean out a /mnt or /var/log in a container, service, or swarm based on some criteria (number of files, or their total size) is there a way to do that?
I've RTFM'd the v1.28 API doc but I only see references to SpaceReclaimed in the "Responses" section, neither did the prune documentation itself provide any clues (although I'm probably not understanding what --filter does).
The response to your question is no, there is no way to control the RECLAIMABLE number because Docker this a field calculate by summing the amount of space used by images that are not used by any container.
You can see my answer to the question you referred here.
One can use the command docker system df (mirror) (introduced in Docker 1.13.0) to see docker disk usage, e.g.:
username#server:~$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 44 28 114.7GB 84.84GB (73%)
Containers 86 7 62.43GB 41.67GB (66%)
Local Volumes 2 1 0B 0B
Build Cache 0B 0B
How is the "RECLAIMABLE" displayed in docker system df computed? I.e., what does it represent?
The Docker documentation on docker system df (mirror) doesn't explain it. The Docker glossary (mirror) doesn't contain the term "RECLAIMABLE".
Hi #Franck Dernoncourt!
RECLAIMABLE is the space consumed by "unused" images (in the meaning of no containers based on thoses images is running).
In other words and as #jordanm said, this is the total size of images you can remove without breaking anything, that is exactly why Docker will remove them if you run docker system prune -a or docker image prune -a. The -a tells Docker to remove all unused images, without it Docker only removes dangling (untagged) images.
You can learn more on how optimize your disk space with Docker here and here and of course Docker documentation for docker image prune and docker system prune.
It's worth mentioning in addition to Kerat's answer, the command you may be looking for to free up space listed as RECLAIMABLE is docker system prune -a --volumes. Volumes will not be pruned by default if you don't include the --volumes flag.
One can use the command docker system df (mirror) (introduced in Docker 1.13.0) to see docker disk usage, e.g.:
username#server:~$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 44 28 114.7GB 84.84GB (73%)
Containers 86 7 62.43GB 41.67GB (66%)
Local Volumes 2 1 0B 0B
Build Cache 0B 0B
What does "active" mean? I.e., what characterizes an image or a container as active?
The Docker documentation on docker system df (mirror) doesn't explain it. The Docker glossary (mirror) doesn't contain the term "active".
I understand that:
"active" container means that the container is currently running (active containers can be listed with docker ps or equivalently docker container ls).
I believe it means:
Images: there is a container that exists using this image
Containers: container is currently running
Volumes: there is a container that exists with this volume mounted