Clearing Docker Container Logs

Finding the large log file

To identify the largest log file, run the below command (Based on a standard docker installation):

for i in $(docker ps --format '{{.Names}}'); do j=$(docker inspect $i -f '{{.LogPath}}'); s=$(du -sh $j); echo "$i $s ($j)"; done

This will show you the container name, log file size and location for each container on your system

Clearing the Log file

To clear the docker log file for a specific container – Copy the location (3rd Column from the output of the above command) and run the following:

truncate -s 0 [Full path to log file]

Any comments or questions? Get in touch here or Email me at [email protected]