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

MacosDocker

Macos Problem Overview


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.

Macos Solutions


Solution 1 - Macos

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!

Solution 2 - Macos

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

Solution 3 - Macos

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.

Solution 4 - Macos

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

Solution 5 - Macos

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

Solution 6 - Macos

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

Solution 7 - Macos

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 https://stackoverflow.com/questions/32485723/docker-increase-disk-space

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGregView Question on Stackoverflow
Solution 1 - MacosunthinkinglyView Answer on Stackoverflow
Solution 2 - MacosQuoting EddieView Answer on Stackoverflow
Solution 3 - MacoslvthilloView Answer on Stackoverflow
Solution 4 - MacosEdwin RodriguezView Answer on Stackoverflow
Solution 5 - MacosAlex LapaView Answer on Stackoverflow
Solution 6 - MacosChristopher FranciscoView Answer on Stackoverflow
Solution 7 - MacosMykola GurovView Answer on Stackoverflow