Advertisements
Recently, we needed to delete the logs of a running docker setup. To do so, we used the following horrible solution:
First, we executed docker system info | grep "Docker Root Dir";
to get the installation path of docker. It resulted to the following:
Docker Root Dir: /var/lib/docker
Then, we truncated all log files using the following command while executing as root:
truncate -s 0 /var/lib/docker/containers/*/*-json.log;
Bonus
To make the command a onliner, use the following:
sudo sh -c 'truncate -s 0 $(docker system info | grep "Docker Root Dir" | cut -d ":" -f2 | cut -d " " -f2-)/containers/*/*-json.log';