Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reduce space used by Docker in MacOS? [closed]

Tags:

docker

macos

I am running very low on disk space (only 11G free of a 512G SSD drive). I need some more space for my development work.

One of the big files identified by the app CleanMyMac X is this one: /Users/antkong/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

enter image description here

I have done a docker images and they cannot add up to 64G

$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
zookeeper               3.4.14              ab94f52d366f        13 days ago         256MB
node                    10                  aa5532763c11        2 weeks ago         911MB
mongo                   4                   bcef5789979d        2 weeks ago         386MB
solr                    6                   0f559c1dfcc2        5 weeks ago         425MB
amazon/dynamodb-local   latest              2908e432b67a        6 weeks ago         611MB
grokzen/redis-cluster   latest              05627925dc7b        7 weeks ago         540MB
mysql-server            8.0                 a7a38888d42d        8 weeks ago         381MB
redis                   5.0.6               de25a823540b        4 months ago        98.2MB
solr                    7.4.0               9a5ffdc62a3d        13 months ago       679MB

Is there any way I can reduce the size of this file?

like image 657
Anthony Kong Avatar asked Dec 17 '22 13:12

Anthony Kong


2 Answers

I assume you've already tried running docker system prune? That command will tell you it removes stopped containers, dangling images, and build cache from old images. The extra space could be from build cache and that wouldn't show up from the list of images.

This page gives more information about how Docker Desktop handles storage (from another commenter): Docker For Mac Storage

tldr: How you reduce the space Docker's using claiming on your system, from the docs: reduce maximum file size

  1. Open Docker Desktop and select Preferences > Resources > Advanced
  2. The Disk image size section contains a slider that allows you to change the maximum size of the disk image. Adjust the slider to set a lower limit.
  3. Click Apply & Restart.
like image 190
tentative Avatar answered Jan 21 '23 16:01

tentative


If you want to get rid of persistent data as well, you can use:

docker system prune -a --volumes

One problem that you will still face is that the file size Docker.raw will start small, but keep increasing over a period of time due to disk activity. To avoid that, one trick that I usually do is to reduce the size to 8GB and increase it back to 32GB using Docker preferences.

like image 38
Rahul Soni Avatar answered Jan 21 '23 17:01

Rahul Soni