I want to automatically clear Docker container logs based on a specific timestamp, such as removing logs older than 30 minutes. However, I am having trouble configuring the compose file to achieve this. Currently, I am only able to control the log file size using the max-size: "" attribute, limiting it to 4KB. Can I accomplish this through a Docker Compose file? If not, how can I achieve this goal? Here's the Docker Compose file I've been using:
version: "3" services: azure-function-app: build: context: . dockerfile: FunctionApp01/Dockerfile image: functionapp-nolimit container_name: function_app-nolimit restart: unless-stopped tty: true ports: - "8081:80" logging: options: max-size: "4k"
I attempted to clean logs based on their size limit. However, when the size limit is exceeded, all previous logs are deleted, which does not meet my objective. My goal is to delete logs that are older than a specific timestamp.