Is there a way to determine the size of a docker volume on my macOS machine?
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.
You can use:
docker system df -v
More info at https://docs.docker.com/engine/reference/commandline/system_df/
Building on Federkun's answer:
docker run --rm -v /:/vm-root alpine du -sH /vm-root/$(docker volume inspect --format '{{ .Mountpoint }}' volumeNameHere)
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)