Manually Truncating Docker Logs

Over the past couple weeks I’ve been redesigning my office and one thing I wanted to do once finishing is make sure my home server is still up and operational.

I came to find out that it ran out of disk space so processes weren’t starting and naturally the only thing I was able to do is SSH into a zero percent disk space environment.

It took me a while to find out exactly what the issue was but it turned out to be Docker Daemon logs for some micro-services containers I have running.

The HD for the server is relatively small – like 12GB small – so once I figured this out and truncated the logs – everything booted like a charm.

Quick wildcard command I came up with:
truncate -s 0 /var/lib/docker/containers/*/*-json.log

Quick Cronjob:
Command – crontab -e
Entry to Insert – */30 * * * truncate -s 0 /var/lib/docker/containers//-json.log >/dev/null 2>&1

Here was the solution I followed from user kaushik on StackOverflow – the only difference is that I did “truncate -s 0 filename.log” instead of “cat /dev/null”

https://stackoverflow.com/a/62554053/2520289

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s