docker: running out of drive space /var/lib/docker/overlay2

Having issues with space filling up on your Docker or container hosts particularly on the/var/lib/docker/overlay2? There is is known side effect that occurs for containers that have been running a long time. You may choose to stop your containers and do a “docker prune -a” to clean your data, but you can also simply clean up the logs.

You can run the following commands to prune your logs and reclaim space. I was able to claim back over 30GB of storage from containers that have been running for about 6 months.

find /var/lib/docker/containers -type f -name “*.log” | xargs du -sh
truncate -s 0 /var/lib/docker/containers/*/*-json.log