How to clear docker container logs without bring the network down

docker

(Varun Raj) #1

I’m sure a lot of us would have faced this issue of storage getting filled without doing anything. This might be majorily because our docker logs would have consumed it fully.

I was wondered to see that a log file was consuming 10GB of HDD storage.

In order to get back the storage we need to truncate the files. First find which are the large files.

du -d1 -h /var/lib/docker/containers | sort -h

And then truncate the files with following command.

cat /dev/null > /var/lib/docker/containers/container_id/container_log_name