What characterizes a Docker image or container as active? - docker

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

Related

How to find active docker images and volumes?

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

inconsistency between "docker system df" and Docker Desktop on Mac

#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.

docker clean up container overhead

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

What is the "RECLAIMABLE" space displayed in docker system df?

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.

Unable to access directory added in docker container

I am trying to add a directory in the container I just created but can't following steps I have taken.
docker images
isbhatt/prefixman v1 cbeed3545d24 About an hour ago 1.044 GB
Then
docker run -v /media/sf_MY_WINDOWS/GitRepo/SDS/SDSNG/:/tmp/SDSNG --name "prefixman_v1" isbhatt/prefixman:v1
Then committing into that container
docker commit -m "prefixman_v1" 35fb30be015c
which gave me an id and I tagged the image on it by
docker tag b9873e80b6d0d68bf605b1ead34ba08f2c044b6cea03f7f57553a97f89845fbe prefixman_v1
Then I started container on fresh image by running
docker run -it prefixman_v1 /bin/bash
So, what I can see is that I can see SDSNG directory in /tmp in container but that directory is empty.
Where am I going wrong??
To elaborate on what larsks said, you should read my answer to Can Docker containers (NOT Docker images) be moved?
A docker container is a process, isolated, with a network card, and by default, 10 GB of disk space. This 10 GB should be quite enough for some code and some config files. If you need to deal with data, docker offers volumes.
A must-read is
https://docs.docker.com/userguide/dockervolumes/
or
http://container-solutions.com/understanding-volumes-docker/

Resources