No Space on CentOS with Docker

I was using Docker on my CentOS machine for a while and had lot of images and containers (around 4GBs). My machine has 8GBs os storage and I kept getting an error from devicemapper whenever trying to remove a Docker container or Docker image with docker rm or docker rmi. The error was: Error response from daemon: Driver devicemapper failed to remove root filesystem. So I stopped the Docker service and tried restarting it, but that failed due to devicemapper. After that I uninstalled Docker and removed all images, containers, and volumes by running the following command: rm -rf /var/lib/docker. However, after running that it does not seem like any space was freed up:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      8.0G  7.7G  346M  96% /
devtmpfs        1.8G     0  1.8G   0% /dev
tmpfs           1.8G     0  1.8G   0% /dev/shm
tmpfs           1.8G  193M  1.6G  11% /run
tmpfs           1.8G     0  1.8G   0% /sys/fs/cgroup
tmpfs           361M     0  361M   0% /run/user/1000

$ du -ch -d 1 | sort -hr
3.6G    total
3.6G    .
1.7G    ./usr
903M    ./var
433M    ./home
228M    ./opt
193M    ./run
118M    ./boot
17M     ./etc
6.4M    ./tmp
4.0K    ./root
0       ./sys
0       ./srv
0       ./proc
0       ./mnt
0       ./media
0       ./dev

Why does df tell me I am using 7.7G whereas du tells me I am using 3.6G? The figure that du gives (3.6G) should be the correct one since I deleted everything in /var/lib/docker.

  • Docker devicemapper storage space
  • Installing Docker on an isolated (no internet) Centos 7 box?
  • docker image - centos 7 > ssh service not found
  • Create base docker centos image with python 2.7.8
  • Why would I need to run docker privileged to access host log4j2.yaml
  • docker : can't mount some directory from host
  • lsmod returns empty output on Jelastic
  • Installing Docker on CentOS 6.6
  • Docker - managing size of containers
  • Docker - How to analyze a container's disk usage?
  • How to install docker-engine using docker binary without internet connection
  • socket failed Too many open files error Docker
  • One Solution collect form web for “No Space on CentOS with Docker”

    I had a similar issue. This ticket was helpful.

    Depending on the file system you are using, you will want to use either fstrim, zerofree or add the drive to another machine or and use use xfs_repair

    If your file system is xfs and you used xfs_repair then after running that command there should be a lost+found directory at the root of the drive that contains all the data that was taking upspace but unreachable.

    You can then delete that and it will actually be reflected in du.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.