67

I have Docker installed on my Mac OS Catalina and recently found very big file Docker.raw. It is 64 Gb.

I don’t understand why is it so big.

Is it really needed?

0

5 Answers 5

85

Docker for Mac stores Linux containers and images in a single, large file named Docker.raw. To reduce its size, after having pruned the unused docker objects ( https://docs.docker.com/config/pruning/ ), open the Docker Desktop preferences, and then under 'Resources' -> 'Advanced' -> 'Disk image size':

Screenshot Resources -> Advanced -> Disk image size

You can reduced file to less than 64GB. it's telling you how much is currently used by the current data. Also Resizing to a smaller size will delete the disk image; all Docker images / containers will be lost. Other settings will be preserved.


If you want to preserve the image, you can use this script : clean-docker-for-mac.sh

The script do this :

  1. SAVE needed image to exclude
  2. DELETE Docker.raw
  3. LOAD chosen image back
0
13

The answer to your question is in the Docker documentation:

Disk utilization in Docker for Mac

Docker Desktop stores Linux containers and images in a single, large “disk image” file in the Mac filesystem. This is different from Docker on Linux, which usually stores containers and images in the /var/lib/docker directory.

The size of this file is big in your system because you have a lot of images and containers. You can reduce its site by pruning unused objects.

1
  • 5
    nope, the Docker.raw file has a fixed size on Mac OS, which is set in the preferences, and AFAIK the default size is 64GB on a 512G Macbook, and 32G on a 256G Macbook, which you can manually set it to a minimum of 8G I think, and it will take up that much disk space despite whether you have any images and containers or not.
    – hellopeach
    Commented Aug 28, 2022 at 6:38
7

The easiest way to reduce Docker.raw file size is by setting the preferences, as Docker official page states:

Select the Docker icon and then select Preferences > Resources > Advanced.

https://docs.docker.com/desktop/mac/space/

Source:https://docs.docker.com/desktop/mac/space/

2

It is very important to note that the "size of the file" and "how much space it occupies on your disk" are not the same thing, because files may be "sparse", and Docker.raw is indeed an example of a sparse file.

For example, on my disk it looks like I have a 60G Docker.raw file. However, it only actually takes up 9.9G on disk:

% cd ~/Library/Containers/com.docker.docker/Data/vms/0/data

% ls -lh Docker.raw 
-rw-r--r--@ 1 ken  staff    60G Jan 15 15:19 Docker.raw

% du -sh Docker.raw 
9.9G    Docker.raw

9.9G is still kinda big, but it makes sense given my usage.

So before tearing your hair out or taking drastic measures that might break something, make sure you actually have a problem worth solving.

1

If you've tried pruning everything but still cannot get your disk usage back to normal, there is a utility in docker desktop in the Troubleshoot menu, which you can get to by clicking the little bug icon in the menu bar. Running the Clean / Purge data utility fixed this for me.

2
  • How does this answer the question? I don't really see the link...
    – Thinkr
    Commented May 22, 2023 at 19:07
  • Instruction that was selected as answer explains how to limit the size available for docker images, this shows a way how to clean docker data. Commented May 30, 2023 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .