Greg
Greg

Reputation: 11512

How can I fix Docker/Mac no space left on device error?

I have built a pretty big image (1G) that has a lot of "infrastructure" in it for testing (Mongo, Kafka, etc.)

When trying to start this I get no space left on device errors. How can I fix this?

I've cleaned off stopped images and removed any images I don't absolutely need.

Upvotes: 84

Views: 74653

Answers (8)

suzukimilanpaak
suzukimilanpaak

Reputation: 808

In Docker version 4.28.0, navigate to Settings > Resources. Right under the section for Virtual Disk Limit, you'll find Disk Image Location. Copy that line and run the following command to check the volume used.

% du -hs /Users/tatsuya.suzuki/Library/Containers/com.docker.docker/Data/vms/0/data
 83G    /Users/tatsuya.suzuki/Library/Containers/com.docker.docker/Data/vms/0/data

enter image description here

Upvotes: 3

Quoting Eddie
Quoting Eddie

Reputation: 1791

You can resize the virtual disk image size in Docker for Mac's Preferences in the Disk tab. This will increase the space without data loss.


In newer versions, the settings can be found in the Resources tab (sub-tab "Advanced"): Option name: Disk image size

Upvotes: 142

Edwin Rodriguez
Edwin Rodriguez

Reputation: 163

Try increasing your disk space. This is what worked for me. Docker -> preferences -> disk -> Disk image size (increase it) -> Apply

Upvotes: 9

Christopher Francisco
Christopher Francisco

Reputation: 16258

You can click on the Docker icon at the top, then preferences. Go to the reset tab and click on remove all data.

Upvotes: 2

Alex Lapa
Alex Lapa

Reputation: 1159

You can update size of a hard drive available for vm in $HOME/.docker/machine/machines/default/config.json

Upvotes: 3

unthinkingly
unthinkingly

Reputation: 1687

If you get no space left on device error with Docker, you might be able to solve this easily with system prune.

I use Docker for Mac 17.03.

With docker UP and all your containers RUNNING, execute docker system prune -a

This should give the following dialog:

WARNING! This will remove:
- all stopped containers
- all volumes not used by at least one container
- all networks not used by at least one container
- all images without at least one container associated to them Are you sure you want to continue? [y/N]

Then press y to delete lots of containers, concluding (in my case) with: Total reclaimed space: 23.26 GB.

Now you can go back to work without even rebooting docker!

Upvotes: 154

lvthillo
lvthillo

Reputation: 30723

Check your directories of docker to locate your problem (on MAC this will be different but the same approach could help)

du -hs /var/lib/docker

You're able to see which folder is taking a lot of disk space by performing the same command on subfolders of /var/lib/docker :

  • For /var/lib/docker/volumes: You have to delete 'orphaned' volumes. You can also use docker volume ls -qf dangling=true to check the volumes. To delete the orphaned volumes: docker volume rm $(docker volume ls -qf dangling=true)

  • For /var/lib/docker/containers you have to check if you have a lot of stopped (or running) containers with docker ps = running containers and docker ps -a = all containers (running and stopped). To delete stopped containers: docker rm -v $(docker ps -aq). The -v flag will automatically delete the volume of the container

  • For /var/lib/docker/images you can delete all your unused images by using docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

Also check GitHub to find some very useful scripts which delete you unused images/containers/volumes.

Upvotes: 16

Mykola Gurov
Mykola Gurov

Reputation: 8685

You can always drop and recreate the boot2docker vm anew to make sure only the needed images/containers are built/imported anew. If you keep hitting the space issue you might want to give your boot2docker vm bit more space, see Docker increase disk space

Upvotes: 0

Related Questions