How to persist logs in docker on host machine

I’m running strapi container in Docker on a Ubuntu machine, everytime when there’s a new version of strapi, I will upgrade the version numbers in package.json, run docker compose down and docker compose up -d to start a new container.

However, everytime when I start a new container, the logs of the old container get lost. Until these have I found this situation.

So, I have two problems:

  1. How to keep existing logs before I execute docker compose down?
  2. How to config Docker to persist logs instead of losing them everytime I start a new container?

Thank you.