DEV Community

sot528
sot528

Posted on

Remove unnecessary Docker resources.

Problem

Using Docker for Mac long time uses large storage spaces.

sot-mbp:clean_docker_resources sot528$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              152                 2                   37.57GB             35.79GB (95%)
Containers          4                   0                   35.8MB              35.8MB (100%)
Local Volumes       4                   0                   7.118MB             7.118MB (100%)
Build Cache         0                   0                   0B                  0B

Solution

docker system prune

Then, SIZE is be around 30GB.
And remove old images without recent 10 images.

docker rmi -f $(docker images | sed -n '10,$p')

Result

Good!

sot-mbp:clean_docker_resources sot528$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              7                   0                   5.337GB             5.337GB (100%)
Containers          0                   0                   0B                  0B
Local Volumes       4                   0                   7.118MB             7.118MB (100%)
Build Cache         0                   0                   0B                  0B

Environment

  • macOS Mojave 10.14.3(18D109)
  • Docker version 18.09.2, build 6247962

Discussion (0)