Log/Data rotation in Docker Container My question is more on the concept or best practices to follow.
I have two docker containers running InfluxDB and Grafana (monitoring applications). I have mounted external volume to each.
now, the problem is, these containers are running for quite some time (1 year approx), i am little bit worried about Host VM resources on which these containers are running. specifically storage resources as these are monitoring applications, which may be storing some data for historical purpose as well.
So, my ask is, what is the best practice to manage logs/data stored in docker volume. I don't want my Host VM to go out of storage and crash my containers.
Any possible solution, if we can rotate stored data so that my container won't stop and i have the historical data as well. or if possible from application point of view (InfluxDB and Grafana) to archive old data.
Thanks in advance... Please let me know if you need more details on this.
below is my docker-compose.yml file
version: &quot;2&quot;
services:
  grafana:
    image: grafana/grafana
    container_name: grafana
    user: root
    privileged: true
    restart: always
    ports:
      - 3000:3000
    networks:
      - monitoring
    volumes:
      - grafana-volume:/var/lib/grafana
  influxdb:
    image: influxdb
    container_name: influxdb
    restart: always
    ports:
      - 8086:8086
    networks:
      - monitoring
    volumes:
      - influxdb-volume:/var/lib/influxdb
networks:
  monitoring:
volumes:
  grafana-volume:
    external: true
  influxdb-volume:
    external: true
You can update the daemon.json config to specify your normal syslog driver (assuming linux) to use the normal syslog logrotation method for keeping log files or shipping off-box
https://docs.docker.com/config/containers/logging/syslog/
{
  &quot;log-driver&quot;: &quot;syslog&quot;,
  &quot;log-opts&quot;: {
    &quot;syslog-address&quot;: &quot;udp://localhost:514&quot;
  }
}