dockermacoscontainersdiskspace

Docker filling up storage on macOS


I noticed that every time I run an image and delete it, 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 in fact were 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?


Solution

  • 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