Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to determine the size of a docker volume on my macOS machine?

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?

like image 308
Bonifacio2 Avatar asked Aug 09 '19 13:08

Bonifacio2


People also ask

How do I find the size of a docker image?

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.

Where are docker volumes on MacOS?

MacOS: ~/Library/Containers/com. docker. docker/Data/vms/0/

How do I find the size of a docker volume?

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.

How do I access docker volume data on Mac?

docker. docker/Data/vms/0/tty to get into the vm and then navigate to the folder to see the volumes.


3 Answers

You can use:

docker system df -v

More info at https://docs.docker.com/engine/reference/commandline/system_df/

like image 140
MikeWu Avatar answered Nov 11 '22 00:11

MikeWu


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)
like image 41
Federkun Avatar answered Nov 11 '22 01:11

Federkun


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.

like image 3
Bonifacio2 Avatar answered Nov 10 '22 23:11

Bonifacio2