I'm aware of docker volume ls
and docker inspect -s
, but the former doesn't show size info and the latter, even though it has a --size
option, ignores it for volumes.
Is there something I'm missing?
To measure the uncompressed size of a Docker image, it is easiest to pull the image locally. You can then retrieve the size of the image with the docker inspect command.
MacOS: ~/Library/Containers/com. docker. docker/Data/vms/0/
By default, if you run docker images you will get the size of each image. However, if you run docker ps you would not get the size of the running containers. To check the size of each running container what you could do is just use the --size argument of docker ps command.
docker. docker/Data/vms/0/tty to get into the vm and then navigate to the folder to see the volumes.
You can use:
docker system df -v
More info at https://docs.docker.com/engine/reference/commandline/system_df/
This:
docker volume inspect --format '{{ .Mountpoint }}' volumeNameHere
will return the mount point of the volume on your host. So, to get the size, it's just a matter of doing:
du -sh $(docker volume inspect --format '{{ .Mountpoint }}' volumeNameHere)
The first step of Federkun's answer worked for me and it returned something like this:
/var/lib/docker/volumes/f4678f...b87/_data
But when I tried
du -sh $(docker volume inspect --format '{{ .Mountpoint }}' volumeNameHere)
it returned a
du: /var/lib/docker/volumes/f4678f...b87/_data: No such file or directory
It turns out Docker works differently on macOS. According to this answer, before I can run the du -sh
command I must first screen
into the docker virtual machine used by MacOS. You can do so by running
sudo screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
and then you can run
du -sh /var/lib/docker/volumes/f4678f...
to finally get the volume size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With