Save docker container log files before container restart

Viewed 426

I have a docker container that I run using the --restart always flag. And everytime the container restarts, it seems to discard the previous run log files. Is there a way to save the logs file even after a restart?

Thanks

1 Answers

Well, There are many ways to get done it, the one could be using a file where you saved all containers logs like this

docker logs --details -f --tail=20 -t container_id ||container_name >> ~/test.txt

I have tested it with a Django app it works well but I usually use volumes to get logs containers.

Related