As we know, we can map files from host machine to docker container.
We also know that there are some OS tools, which can help us to rotate log files.
Now I use
docker-compose to run a container with some file mapping. Here is my
version: "3.5" x-volumes-common: &volumes_common - "./openfire_https.log:/openfire_https.log:rw" - "./openfire_tcp.log:/openfire_tcp.log:rw" services: envoy: image: xxx/yyy volumes: *volumes_common ports: - "9999:9999"
As you see, two log files are mapping from the host machine to the docker container.
I have to try to rotate the two log files periodically since this container provides some web services and write logs into the two files.
I’m not sure if it is possible or is a proper way to rotate the two files from the host machine (Ubuntu16.04) with the tool
logrotate as the two files are mapped from the host machine, I don’t know if I rotate them from the host machine immediately, what would happen, will it work as I expected?