DEV Community

sot528
sot528

Posted on

5 1

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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay