“no space left on device” even after removing all containers

后端 未结 3 1326
我在风中等你
我在风中等你 2021-02-05 15:26

While experimenting with Docker and Docker Compose I suddenly ran into \"no space left on device\" errors. I\'ve tried to remove everything using methods suggested in similar qu

3条回答
  •  孤独总比滥情好
    2021-02-05 16:08

    This may not directly answer the question but it can be useful in general if the Dockerfile used to create the image is available.

    Make sure in particular to limit the number of layers that will be generated, hence, when writing the Dockerfile, avoid doing this:

    RUN apt-get update && sudo apt-get install -y package1 
    RUN apt-get update && sudo apt-get install -y package2 
    RUN apt-get update && sudo apt-get install -y package3 
    

    and do this instead:

    RUN apt-get update && sudo apt-get install -y \
        package1 \
        package2 \
        package3 
    

    Doing so drastically reduced the size of the image as well as the inode usage, since less layers are generated. This helped address the issue in my case (where the inodes would all get used up).

    Make sure to remove the potential intermediate image that was generated by the failed build to free up space docker rmi .

    For more tips, you can check out this site about Optimizing Docker images.

提交回复
热议问题