How to clean up Docker

The following is a radical solution. IT DELETES ALL YOUR DOCKER STUFF. INCLUDING VOLUMES.

$ sudo su
# service docker stop
# cd /var/lib/docker
# rm -rf *
# service docker start

See https://github.com/moby/moby/issues/22207#issuecomment-295754078 for details

It might not be /var/lib/docker

The docker location might be different in your case. You can use a disk usage analyzer (such as mate-disk-usage-analyzer) to find the folders which need most space.

See Where are Docker images stored on the host machine?


This dir is where container rootfs layers are stored when using the AUFS storage driver (default if the AUFS kernel modules are loaded).

If you have a bunch of *-removing dirs, this is caused by a failed removal attempt. This can happen for various reasons, the most common is that an unmount failed due to device or resource busy.

Before Docker 17.06, if you used docker rm -f to remove a container all container metadata would be removed even if there was some error somewhere in the cleanup of the container (e.g., failing to remove the rootfs layer). In 17.06 it will no longer remove the container metadata and instead flag the container with a Dead status so you can attempt to remove it again.

You can safely remove these directories, but I would stop docker first, then remove, then start docker back up.

Tags:

Docker