简体   繁体   中英

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.

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!

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" ): 选项名称:磁盘映像大小

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.

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

您可以在$HOME/.docker/machine/machines/default/config.json更新可用于 vm 的硬盘驱动器的大小

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM