there are situations when you need to quickly free up space on your kubernetes worker nodes. sometimes just temporarly to extend the vg for the local filesystem.
here is a quick way to truncate the logs of the docker containers on a node
first you have to get the docker containers on the host
we just need the container IDs so we use the option “-q”:
docker ps -q

then we want to get the logpath of every container:
docker inspect –format='{{.LogPath}}’ <container name>
we use the magic of bash to show us the logs of every container:
docker inspect –format='{{.LogPath}}’ $(docker ps -q)

and finally we can truncate them to free up some space in the filesystem:
truncate -s 0 $(docker inspect –format='{{.LogPath}}’ $(docker ps -q))

we can verify the disk usage of the logs with the following command:
du -h $(docker inspect –format='{{.LogPath}}’ $(docker ps -q))
