Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: "You don't have enough free space in /var/cache/apt/archives/"

Tags:

docker

I have a dockerfile which when I want to build results in the error

E: You don't have enough free space in /var/cache/apt/archives/

Note that the image sets up a somewhat complex project with several dependencies that require quite a lot of space. For example, the list includes Qt. This is only a thing during the construction of the image, and in the end, I expect it to have a size of maybe 300 MB.

Now I found this: https://unix.stackexchange.com/questions/578536/how-to-fix-e-you-dont-have-enough-free-space-in-var-cache-apt-archives

Given that, what I tried so far is:

  • Freeing the space used by docker images so far by calling docker system prune
  • Removing unneeded installation files by calling sudo apt autoremove and sudo apt autoclean
  • There was also the suggestion to remove data in var/log, which has currently a size of 3 GB. However, I am not the system administrator and thus wary to do such a thing.

Is there any other way to increase that space?
And, preferably, is there a more sustainable solution, allowing me to build several images without having to search for spots where I can clean up the system?

like image 969
Aziuth Avatar asked Dec 14 '20 14:12

Aziuth


3 Answers

Converting a @Dre suggestion into the code, you might want to use Docker prune command for containers, images & volumes

docker container prune
docker image prune
docker volume prune

You can use these commands in sequence:

docker container prune; docker image prune; docker volume prune
like image 56
Roman Avatar answered Oct 17 '22 21:10

Roman


Try this suggestion. You might have a lot of unused images that need to be deleted. https://github.com/onyx-platform/onyx-starter/issues/5#issuecomment-276562225

like image 17
Dre Avatar answered Oct 17 '22 21:10

Dre


TLDR;

run

docker system prune -a --volumes

I tried to increase the disk space and prune the images, containers and volumes manually but was facing the issue again and again. When I tried to check the memory consumption on my machine, I found a lot of memory consumed by ~/Library/Containers/com.docker.docker location. Did a system prune which cleaned up a lot of space and docker builds started working again.

like image 6
Karan Sharma Avatar answered Oct 17 '22 22:10

Karan Sharma