117

I am learning docker and I am using v1.11.0 I am trying to install hadoop but devmapper is complaining about free disk space?

devmapper: Thin Pool has 82984 free data blocks which is less than minimum required 163840 free data blocks. Create more free space in thin pool or use dm.min_free_space option to change behavior

I have deleted all my images but the problem persists:

[root@localhost hadoop_docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
debian              latest              47af6ca8a14a        3 weeks ago         125 MB
[root@localhost hadoop_docker]#

and this is my disk configuration:

[root@localhost ~]# lsblk
NAME                       MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                          8:0    0    8G  0 disk
├─sda1                       8:1    0  500M  0 part /boot
└─sda2                       8:2    0  7.5G  0 part
  ├─centos-root            253:0    0  6.7G  0 lvm  /
  └─centos-swap            253:1    0  820M  0 lvm  [SWAP]
sr0                         11:0    1 1024M  0 rom
loop0                        7:0    0  100G  0 loop
└─docker-253:0-844682-pool 253:2    0  100G  0 dm
loop1                        7:1    0    2G  0 loop
└─docker-253:0-844682-pool 253:2    0  100G  0 dm

How can I free up the disk space?

Timothy G.
  • 6,335
  • 7
  • 30
  • 46
masber
  • 2,875
  • 7
  • 29
  • 49
  • 1
    Is this also related to devicemapper in loopback unrecoverable storage issues ? https://github.com/docker/docker/issues/3182 "devicemapper not recommended for production use". Better move away from devicemapper for a few reasons. I found it easy enough to switch to overlay storage driver, YMMV of course but hopefully not too much. 'rm -rf /var/lib/docker' is somewhat optional when switching but easy and I would highly recommend it. http://www.projectatomic.io/blog/2015/06/notes-on-fedora-centos-and-docker-storage-drivers/ – gaoithe Mar 31 '17 at 11:25
  • 1
    FYI, you can see thin pool disk usage with "`sudo lvs`". This helps when you are trying to figure out "how much" disk space you need to clean up (using the given answers). – Aaron D. Marasco Apr 11 '17 at 10:35

2 Answers2

183

Just run these three. No need to remove RUNNING containers.

  1. Cleanup exited processes:

    docker rm $(docker ps -q -f status=exited)
    
  2. Cleanup dangling volumes:

    docker volume rm $(docker volume ls -qf dangling=true)
    
  3. Cleanup dangling images:

    docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
    
cfrick
  • 35,203
  • 6
  • 56
  • 68
Cokorda Raka
  • 4,375
  • 6
  • 36
  • 54
  • 4
    I learned it from here: http://stackoverflow.com/questions/32723111/how-to-remove-old-and-unused-docker-images – Cokorda Raka Dec 12 '16 at 04:56
  • Just stumbled upon this: https://github.com/ajohnstone/dot-files/blob/master/bash.d/bash/docker This guy has some nifty functions for working with Docker. Just save as executable, and "source dokermagik.sh", and enjoy. – Cokorda Raka Dec 14 '16 at 05:54
  • 23
    Version 1.13 now allows invoking `docker system prune` https://docs.docker.com/engine/reference/commandline/system_prune/ – Vivek Kodira Mar 06 '17 at 15:57
  • 2
    This should probably be the accepted answer. The other answer can potentially kill more containers than you want to kill. – Marc Seiler Mar 20 '17 at 22:11
  • `docker system prune` doesn't clean up dangling images. I really had to run step 2) 3) to recover most of the disk space used up so that my docker engine is usable again. – Soichi Hayashi Mar 27 '17 at 14:23
  • 2
    This commands are very helpful to clean the disk of the machine, but did not fix the problem with the devicemapper and the space. – Paulo Oliveira Sep 22 '17 at 12:36
  • 8
    I still don't understand "what" this error message means, so even if those commands work I wouldn't fully understand why. What is "thin pool"? And what does exiting processes have to do with "freeing data blocks"? – yiati Nov 09 '17 at 17:44
  • 1
    @yiati - run `lsblk` in a terminal and you'll probably see docker has a block device it's running on. This can be a physical device like a HDD or a loopback device (a fake/virtual device stored in a file), but it has a finite amount of space. If you run out of space on this device, that's the error you get. – Matthew Dec 27 '17 at 22:09
  • `docker system prune -a` to remove all the images – Yuvaraj Loganathan Jun 25 '18 at 06:25
  • may the lord praise you @CokordaRaka – tekneee Feb 25 '19 at 15:21
  • Thanks for the answer! I've used it - in addition to the answer by @tidhar below, - and made a docker utility from it: https://hub.docker.com/r/tikalci/tci-docker-cleanup – yorammi Dec 11 '19 at 20:39
47

You can use:

docker system prune -a -f --volumes

where:

  • -a == removes all unused images
  • -f == force
  • --volumes == prune volumes.

see: https://docs.docker.com/engine/reference/commandline/system_prune/#description

as a side note, I had a lot of issues when I used devicemapper driver on my environment. I used to clean as I mentioned, but there were still other devicemapper issues. I strongly recommend moving to overlay2, it solved almost everything completely.

Tidhar Klein Orbach
  • 2,896
  • 2
  • 30
  • 47
  • 1
    We regularly run the commands in @Cokoda-Raka's answer, but oe one particular Docker host, this command was necessary when overaly2 was using up a significant amount of disk space, more than it should have. I think I'll add this command to our automated clean-up tasks as well. – StockB Jul 10 '19 at 13:08
  • 1
    This helped on RHEL 7 with Docker 1.13.1. After running `docker container prune`, `docker image prune`, `docker volume prune`, we still got the devmapper/Thin Pool error. The above command worked, clearing up the necessary space and eliminating the need to restart the daemon. – Johnathan Elmore Jul 26 '19 at 22:48