Docker, containers & VMs

How to Set a Disk Size Limit for Docker Desktop on Mac (Stop Runaway Growth)

If you have ever opened About This Mac and wondered why your SSD is nearly full despite a reasonably tidy home folder, Docker Desktop is a likely culprit. Knowing how to limit Docker Desktop disk size on Mac — and how to recover the space it has already consumed — is one of the highest-impact storage fixes a developer can make on Apple Silicon or Intel hardware running macOS Sequoia or Tahoe.

Why Docker Desktop Grows Without Asking

Docker Desktop on macOS runs inside a lightweight Linux virtual machine. It stores almost everything — images, containers, volumes, and build cache — inside a single sparse disk image. On Apple Silicon Macs that file lives at:

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

On older Intel Macs you may also see a .qcow2 variant in the same directory. The file is a sparse image, so macOS reports a small number on disk, but Docker allocates an upper ceiling — the Virtual Disk Limit — and the file can grow to fill that ceiling as you pull images and create volumes. The default ceiling is 64 GB on most installations, and it rarely shrinks automatically even after you delete containers.

What Is Actually Inside the Docker Disk Image

Before you change the limit, it helps to understand what is consuming space so you know what you can safely remove.

name="row"
Category Typical Size Safe to Delete?
Pulled images (layers) 2 – 20 GB per image Yes, if not actively used
Stopped containers 10 MB – 2 GB each Yes, if not needed
Named volumes Varies (DB data can be large) Only if you have a backup
Build cache 5 – 30 GB Yes — Docker rebuilds on demand
Docker Extensions data 100 MB – 1 GB Yes, if extensions are unused

How to Change the Virtual Disk Limit in Docker Desktop

This is the primary control. Follow these steps:

  1. Open Docker Desktop from the menu bar or Applications folder.
  2. Click the gear icon (Settings) in the top-right corner.
  3. Select Resources in the left sidebar.
  4. Under the Advanced sub-tab, locate Virtual disk limit.
  5. Drag the slider or type a value. A common developer sweet-spot is 32 GB; a CI workstation may need 64–128 GB.
  6. Click Apply & Restart. Docker will restart its VM.

Important: Lowering the limit does not reclaim space automatically. The sparse image file does not shrink just because you reduced the ceiling. You must prune unused data first (see below), then optionally run a compaction step.

Prune Docker Resources Before or After Resizing

Pruning removes objects Docker no longer needs. Run these commands from Terminal:

  • Remove all stopped containers, dangling images, unused networks, and the build cache in one shot:
    docker system prune --all --volumes
  • Or prune selectively:
    docker image prune -a — unused images only
    docker volume prune — volumes not attached to any container
    docker builder prune --all — build cache only

After pruning, check how much space Docker now reports it is using:

docker system df

This command shows a table of images, containers, local volumes, and build cache with their actual disk footprint.

How to Compact the Virtual Disk File on macOS

Even after pruning, the Docker.raw sparse image holds onto freed blocks. To release those blocks back to macOS:

Option A — Docker Desktop's Built-in Cleanup (Docker Desktop 4.x and later)

  1. Go to Settings → Resources → Advanced.
  2. Click Clean / Purge data (label varies slightly by version). This resets the virtual disk entirely, so make sure you have pruned or backed up any volumes you need first.

Option B — Manual Compaction via qemu-img (Intel Macs)

On Intel Macs where the image is in .qcow2 format, you can install qemu via Homebrew and run:

qemu-img convert -O qcow2 Docker.qcow2 Docker-compact.qcow2

Then replace the original. This is an advanced operation; the Docker Desktop GUI method above is safer for most users.

Option C — Reset to Factory (Nuclear Option)

If the disk has ballooned severely and you do not need any local volumes, the fastest recovery is a full factory reset:

  1. Settings → Troubleshoot → Reset to factory defaults.
  2. Docker Desktop deletes the entire ~/Library/Containers/com.docker.docker directory and creates a fresh, small virtual disk.
  3. Re-pull only the images you actually need.

Preventing Runaway Growth Going Forward

Setting a tighter virtual disk limit is only half the battle. Combine it with a few habits:

  • Use a .dockerignore file in every project so build contexts do not balloon with node_modules or build artifacts.
  • Pin image tags rather than using :latest. Pulling :latest repeatedly accumulates dangling layers.
  • Add docker system prune to your CI cleanup scripts so build cache does not accumulate between runs.
  • Use named volumes sparingly. Anonymous volumes created by docker-compose up pile up invisibly. Run docker volume ls periodically to audit them.
  • Schedule a monthly prune. Put docker system prune -f in a cron job or calendar reminder.

Other Developer Folders That Silently Consume Disk Space

Docker rarely acts alone. While you are auditing your disk, check these common offenders:

  • ~/Library/Developer/Xcode/DerivedData — Xcode build artifacts, often 20–50 GB. See our guide on why Xcode takes up so much space.
  • ~/.m2/repository — Maven local cache; can reach 10+ GB on Java projects.
  • ~/.cargo/registry — Rust crate sources and compiled artifacts.
  • node_modules directories scattered across project folders. Our post on cleaning up node_modules on Mac walks through a safe bulk-removal approach.
  • ~/Library/Caches — application caches from Homebrew, npm, pip, and dozens of macOS apps.

A tool like Crumb can audit all of these at once and show what is safe before you delete, so you do not have to remember every path yourself.

Quick Reference: Docker Disk Paths on macOS

What Path (Apple Silicon) Notes
Virtual disk image ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw Sparse file; reported size < allocated ceiling
Docker Desktop app data ~/Library/Containers/com.docker.docker/ Config, logs, extensions
Docker CLI config ~/.docker/ Credentials, contexts, config.json
Docker Desktop app /Applications/Docker.app ~700 MB application bundle

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Is it safe to lower the Docker Desktop virtual disk limit on Mac?
Yes, as long as the data already stored inside Docker fits within the new limit. Prune unused images and volumes first, confirm with <code>docker system df</code> that total usage is below your target limit, then lower the slider. Docker will warn you if existing data would be truncated.
Where is the Docker disk image stored on a Mac?
On Apple Silicon Macs it is stored at ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw. On Intel Macs running older Docker versions you may see a .qcow2 file in the same directory. This single file represents all images, containers, and volumes.
Will lowering the disk limit delete my containers or volumes?
Changing the limit alone does not delete any data. However, if you also run a factory reset or the Clean / Purge data option, all local volumes and images will be removed. Back up any database volumes or important data before using those options.
Why does the Docker.raw file not shrink after I delete images?
The sparse image file reserves blocks for previously written data even after that data is deleted inside the VM. You need to either use Docker Desktop's built-in compaction tool (Settings > Troubleshoot) or perform a factory reset to physically reclaim those blocks on your SSD.
How much disk space should I allocate to Docker Desktop on a Mac?
A typical web developer working with a few services and databases can manage comfortably on 32 GB. If you regularly pull large images (GPU runtimes, full Linux distributions, or many microservices) or run builds that produce big layers, 64 GB is a reasonable ceiling. Avoid leaving it at the default uncapped or very high value unless you genuinely need the headroom.