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.

  • CentOS disable service (docker) before boot?
  • docker linux container doesn't support driver development?
  • Docker> postgresql9.6 error
  • Docker: ping: unknown host yahoo.com
  • Docker error while creating couchbase - ulimit: open files: cannot modify limit: Operation not permitted
  • Clean docker environment: devicemapper
  • How to check the configuration of an app deployed on docker container
  • How to make my docker run on a specified linux kernel version?
  • can not ping as normal user in Docker centos image
  • Exposing Docker application to host
  • docker on centos that has no internet, rpm package dependency issue
  • Docker - Mount docker image's root folder on different Disk
  • 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.