Docker filling up storage on macOS

Franco Rabaglia picture Franco Rabaglia · Oct 5, 2016 · Viewed 29.1k times · Source

(Post created on Oct 05 '16)

I noticed that every time I run an image and delete, my system doesn't return to the original amount of available space.

The lifecycle I'm applying to my containers is:

> docker build ...
> docker run CONTAINER_TAG
> docker stop CONTAINER_TAG
> rm docker CONTAINER_ID
> rmi docker image_id

[ running on a default mac terminal ]

The containers that are created from custom images, running from node and a standard redis. My OS is OSX 10.11.6.

At the end of the day I see I keep losing Mbs. How can I face this problem?

EDITED POST

2020 and the problem persists, leaving this update for the community:

Today running:

  • macOS 10.13.6
  • Docker Engine 18.9.2
  • Docker Desktop Cli 2.0.0.3

The easiest way to workaround the problem is to prune the system with the Docker utilties.

docker system prune -a --volumes

Answer

zhongjiajie picture zhongjiajie · Mar 26, 2019

WARNING:

By default, volumes are not removed to prevent important data from being deleted if there is currently no container using the volume. Use the --volumes flag when running the command to prune volumes as well:

Docker now has a single command to do that:

docker system prune -a --volumes

See the Docker system prune docs