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.

  • Installing rancher 1.6.2 on centos 7
  • Can't access exe symlinks in centos 6.6 on docker
  • What might cause a docker container to execute an su command differently on two hosts?
  • Destroy Docker container from Marathon kills Mesos slave
  • lsmod returns empty output on Jelastic
  • Deploying to dockerized Jboss Zip Exception
  • Iscsid not starting on a centos6 docker on MacOS host
  • Error: docker-engine-selinux conflicts with 2:container-selinux?
  • how to start docker service with a specific port in linux (ubuntu/centos)
  • Jenkins: Can't connect to Docker daemon
  • Deleting devicemapper after changing storage driver
  • How to find Docker REST API URI for Jenkins
  • 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.