Search code examples
dockercaching

Is there any way to clean docker files while keeping its cache?


I'm running a lot of builds using Docker on Linux. Eventually a lot of data is piling up, for example this is what I see in docker system df:

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          247       0         45.03GB   45.03GB (100%)
Containers      0         0         0B        0B
Local Volumes   59        0         0B        0B
Build Cache     118       0         3.487kB   3.487kB

Is there a way to clean up unused images, containers, and local volumes while maintaining the Docker cache?

I tried a docker system prune but I lose some caches that can help me in new builds.


Solution

  • you can also use

    docker builder prune
    

    for cleaning read more at https://docs.docker.com/reference/cli/docker/builder/prune/