Time to time you can find yourself asking a simple question, What filling my disk space in docker host machine ? Well, if you have many containers in single host, or your containers producing too much logs, “out of space” errors are inevitable.
In centos and debian based systems, you can find your container logs /var/lib/docker/containers/ path. You can easily calculate how much space consumed by your container logs with this simple command: du -h --max-depth=1
after that you will know your disk usage. So now you have the knowledge, after that you need to delete your logs, but deleting logs maybe not really good idea, instead you should truncate your logs.
With this command, you can easily truncate all of the container logs truncate -s 0 /var/lib/docker/containers/*/*-json.log
I recommend create a cronjob for this task,
sudo echo "/usr/bin/truncate -s 0 /var/lib/docker/containers/*/*-json.log" > /etc/cron.hourly/dockerlog
Now your container logs will be truncated every hour.