Skip to cookie settings

Docker.raw is huge: what it is and why it does not shrink

Docker.raw is a sparse disk image, so the size Finder shows and the space it really uses can differ a lot. Here is how to tell them apart.

Part of: Docker disk space on Mac: Docker.raw, images and build cache explained (Docker)

Docker.raw is the file where Docker Desktop for Mac keeps all your images, containers and volumes. Its size in Finder is often the maximum Docker may use, not what it uses today. To see the real number, compare two commands, as shown below.

Do not delete the file in Finder. It is Docker’s whole storage in one piece. If you remove it, you remove everything inside it.

What Docker.raw is

Docker runs Linux containers, so on a Mac it starts a small Linux virtual machine. The Docker Desktop for Mac FAQ says Docker “stores Linux containers and images in a single, large ‘disk image’ file in the Mac filesystem”. It gives the usual path as:

~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

Your Docker Desktop version may use a different file name or location, so check that FAQ if the path is missing on your Mac.

Why Finder and Terminal disagree

Docker.raw is a sparse file. A sparse file can claim a large size without storing every byte on disk. The parts nobody has written to take no space.

That gives you two numbers:

  • Apparent size. The maximum the file may grow to. Finder and ls -lh usually show this.
  • Allocated size. The space the file really takes on your disk. du -h shows this.

Docker’s Mac FAQ shows the same idea with ls -klsh Docker.raw: the first column is the real size and the file size column is the maximum. Its example has a 64 GB maximum next to a real size of about 2.3 GB.

I checked the same two commands on a Colima disk file, which is a sparse disk image of the same kind. ls -lh reported the full configured limit, and du -h reported a much smaller number. The two commands are read-only, so you can run them without risk:

cd ~/Library/Containers/com.docker.docker/Data/vms/0/data
ls -klsh Docker.raw

If the first number is far below the second, Docker.raw is not as big as it looks.

Why the file does not shrink after you delete things

You removed images, ran a cleanup, and the file is still big. Two reasons:

  • Docker only frees space when things are really deleted. Its Mac FAQ says “Space is only freed when images are deleted. Space is not freed automatically when files are deleted inside running containers.”
  • Deleting inside the virtual machine does not always hand the space back to the Mac at once. Whether it does depends on the tool and version. The Colima FAQ, for example, says unused disk space is released when the VM starts, for version 0.5.0 and above.

So a small number after cleanup is the goal, and du -h is the honest way to read it.

Is Docker running right now?

Docker Desktop has a Resource Saver mode. Docker’s settings documentation says it “significantly reduces CPU and memory utilization on the host by automatically turning off the Linux VM when Docker Desktop is idle”. That saves memory, not disk. The Docker.raw file stays where it is when the VM is off, so a big file does not mean Docker is busy. It means the data is still stored.

Safe, risky, never

Action Verdict What breaks Cost to recreate
Looking at the file with ls and du Safe Nothing None
Removing unused images and stopped containers inside Docker Safe Nothing you run today Re-pull or rebuild time
Lowering the disk image size limit in Settings Risky Per Docker’s Mac FAQ, this deletes the current disk image, so all containers and images are lost Re-pulling every image and rebuilding every container
Deleting Docker.raw in Finder Never All images, containers and volumes, with Docker still expecting the file Everything, and volume data may be gone for good

What to do

  1. Compare ls -klsh Docker.raw with the maximum size in Docker Desktop settings. The Docker docs describe the size limit as “the maximum amount of disk space the engine can use” in the Advanced Resources settings.
  2. Run docker system df and see which kind of data is biggest. It is read-only.
  3. Remove what you recognise as old, starting with stopped containers and build cache. The overview has the full order.
  4. If you need the space back on the Mac, read the reclaim guide before you change the size limit, because that route deletes data.

Using Colima instead of Docker Desktop? There is no Docker.raw there. See the Colima guide.

How DiskJoy fits in

DiskJoy is our product. It is pre-alpha: it scans and shows reclaimable space, and it is built to report allocated bytes, the number du shows, so a sparse file is not counted at its maximum size. Cleanup is not built yet, so it does not remove or shrink anything today. The download page shows the current status of the scan.

Frequently asked questions

Can I delete Docker.raw?

Do not delete it by hand while Docker is in use. It holds all your images, containers and volumes, so deleting it removes them all. Docker Desktop has its own reset option that removes the disk image in a controlled way.

Why is Docker.raw 64 GB?

That is usually the maximum size of the disk image, not the space it uses. Docker documentation shows an example with a 64 GB maximum and a much smaller real size.

How do I shrink Docker.raw?

Remove what you no longer need inside Docker first. Then, as the Docker Mac FAQ describes, lowering the disk image size limit in Settings replaces the disk image, which deletes all containers and images.

Tags:DockerDocker.rawSparse files

See what’s taking up space on your Mac

DiskJoy explains every item and removes nothing until you review it.
Download for Mac

Cookies on diskjoy.com

Your browser sends a Global Privacy Control signal. We honoured it: analytics and marketing cookies are off.

Necessary cookies run this site. Analytics shows us how it is used: if you accept it, Google receives data about your visit. Change this anytime in Cookie Settings. How Google uses data Cookie Policy Privacy policy

Customize

Purpose
Needed for the site to work and to remember your cookie choice.

Cookies

  • sy_consent - Stores your cookie choice (Retention: 12 months)

Other browser storage

  • sy_consent_pending (localStorage) - Queues your choice until it reaches our server (Retention: until deleted)
Purpose
Show us which pages are visited and how the site is used, so we can improve it. Provider: Google Ireland Ltd (Google Analytics 4).

Cookies

  • _ga - Distinguishes visitors to count them (Retention: 400 days)
  • _ga_TP2XMLG27P - Keeps the state of your current visit (Retention: 400 days)

Recipients

Data controller

Sylentis Group sp. z o.o.. Contact: support@diskjoy.com. Privacy policy

Google may process data outside the European Economic Area (EEA). Safeguards: EU-US Data Privacy Framework, standard contractual clauses.

Right to withdraw

You can withdraw consent at any time, as easily as you gave it. Withdrawal does not affect the lawfulness of processing before it.