How to backup all docker container logs

1.1k Views Asked by At

I am quite new in docker and I don't know if this has been asked before. Is it possible to backup all docker container logs without using volumes for each container? We are using docker on a remote machine (mostly using jenkins)

Right now I am running multiple containers and multiple docker-compose on my remote machine. I want to save the logs (with a retention period of 7 days) for future use.

Is there any available images that can help me with this one? We initially use elk-stack + filebeat but they consume too much resources. Now we are just use dozzle to view logs remotely.

1

There are 1 best solutions below

0
On

After some deliberation, I just did the following commands to backup my logs:

docker ps -a --format {{.Names}} //to get names of docker containers
for each container 
    docker logs container_name > container_name_date.log

forfiles /p <logs location> /s /m *.log* /c \"cmd /c Del @path\" /d -7" //to delete >7 day old log files

Now I am running this script via jenkins pipeline as a daily cron job