Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker no space left on device macOS

I am trying to build a docker image that requires copying some large files (~75GB) and I'm getting the following error when I run the following:

$ docker build -t my-project .
Step 8/10 : COPY some-large-directory
  failed to copy files: failed to copy directory: Error processing tar file(exit status 1): write /directory: no space left on device

I think the error is caused by the container running out of space (I already increased the docker disk image size to 160GB using docker preferences). If so how can I increase the maximum container size on macOS (high sierra) (I read the default is 100GB)?

like image 376
Nick Fernandez Avatar asked Feb 07 '18 16:02

Nick Fernandez


People also ask

How do I free up space on my docker?

A stopped container's writable layers still take up disk space. To clean this up, you can use the docker container prune command. By default, you are prompted to continue. To bypass the prompt, use the -f or --force flag.

How do you free up space if a docker server is running out of space?

We generally try to clean up old images when creating a new one but you could also have this run as a scheduled task on your docker server every day. You need to pass the --volumes flag to prune the volumes as well. Without this only 'unused containers, networks, images (both dangling and unreferenced)' will be pruned.


Video Answer


3 Answers

Docker objects accumulate over time, so with heavy usage you can eventually exhaust the available storage. You can confirm that this is the issue with docker system df:

docker system df

You can start reclaiming some space by doing a prune of your unused objects, a couple examples:

# Prune everything
docker system prune

# Only prune images
docker image prune

Be sure to read the Prune unused Docker objects documentation first to make sure you understand what you'll be discarding.

If you really can't reclaim enough space by discarding objects, then you can always allocate more disk space.

like image 142
Brad Koch Avatar answered Oct 16 '22 18:10

Brad Koch


Instructions on how to increase space:

https://forums.docker.com/t/no-space-left-on-device-error/10894/26?u=adnan

Be aware that untagged images and old containers can take up loads of space.

To delete untagged images use:

docker images (to see what the extent of the issue is), then

docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")

and similarly for containers, try something like

docker rm -f $(docker ps -aq) (this will remove all containers, so be careful)

Updated 2020:

docker system prune is also a quick method of removing old containers and untagged images.

like image 37
PaulNUK Avatar answered Oct 16 '22 16:10

PaulNUK


Increasing the space available to docker using docker preferences in macOS ultimately fixed the problem.

like image 10
Nick Fernandez Avatar answered Oct 16 '22 17:10

Nick Fernandez