Docker Community Forums

Share and learn in the Docker community.

Some way to clean up / identify contents of /var/lib/docker/overlay

clean log file to clean up 10GB for me :stuck_out_tongue:

truncate -s 0 /var/lib/docker/containers/*/*-json.log

You may need sudo

sudo sh -c "truncate -s 0 /var/lib/docker/containers/*/*-json.log"

I’m running a typical homeserver with plex, nextcloud, pihole and a couple of other stuff in docker. I just tried out some steps to reduce the disk usage of docker and I thought you might be interested.

after running docker system prune -a the usage looked like this:

user@Docker:/var/lib/docker$ sudo du -h -d 1
[sudo] password for marius: 
3.2G	./vfs
20K     ./builder
20K	    ./plugins
13G	    ./overlay2
72K	    ./buildkit
4.0K	./trust
148K	./network
2.2G	./volumes
28M	    ./image
4.0K	./tmp
4.0K	./runtimes
132M	./containers
4.0K	./swarm
18G	.

after docker-compose down for every container and pruning again:

3.2G	./vfs
20K     ./builder
20K	    ./plugins
1.3G	./overlay2
72K	    ./buildkit
4.0K	./trust
148K	./network
2.2G	./volumes
16M	    ./image
4.0K	./tmp
4.0K	./runtimes
360K	./containers
4.0K	./swarm
6.6G	.

Then I removed /var/lib/docker (of course I saved /var/lid/docker/volumes beforehand and copied it back aftewards) and brought all my container back up. The disk usage now looks like this:

16K	    ./plugins
11G	    ./overlay2
88K	    ./buildkit
4.0K	./trust
128K	./network
2.2G	./volumes
14M	    ./image
4.0K	./tmp
4.0K	./runtimes
712K	./containers
4.0K	./swarm
13G	.

So it looks like a docker system prune -a does not get rid of all unused files as the usage now is quite a bit lower that it was at the beginning with the same containers running

“docker system prune -a” freed up disk space from /var/lib/docker/overlay2
“docker volume rm $(docker volume ls -qf dangling=true)” freed up disk space from /var/lib/docker/volumes

I had the same issue. These two commands worked for me:

“docker system prune -a” freed up disk space from /var/lib/docker/overlay2
“docker volume rm $(docker volume ls -qf dangling=true)” freed up disk space from /var/lib/docker/volumes

it works, finally found the root cause, application logging files kept inside and keep growing.
thanks