This tutorial will help you clear log file on a Docker container. If your system is getting out of disk space and you found that the docker container’s log files are consuming high disk space. you can find the log file location and clear them with the help of this tutorial. While clearing log files of a docker container, you don’t need to stop it.
Clear Docker Container Log File
Fist of all, find the log file location of a Docker container. Use inspect option to find log file name and location.
docker inspect --format='{{.LogPath}}' <container id/name>
Once you find the log file location, just truncate it with the following command.
truncate -s 0 /path/to/logfile
Here -s
is used to set the size of a file. You provided 0 as input, means completely truncate the log file.
Leave a Reply