2 docker
Markus Bergholz edited this page 4 months ago

syslog logging

/etc/rsyslog.d/30-docker.conf

$template mariadb,"/var/log/containers/mariadb.log"

if $programname == "mariadb" then ?mariadb
& stop

container specs

- name: mariadb
  community.general.docker_container:
    name: mariadb
    image: registry.gitlab.com/markuman/mariadb:10.4.13
    state: started
    auto_remove: yes
    volumes:
      - "{{ DOCKER_DATA }}/mariadb:/var/lib/mysql/"
    network_mode: osuv
    networks_cli_compatible: yes
    env:
      MAX_CONNECTIONS: 150
      MAX_ALLOW_PACKET: 64M
      QUERY_CACHE: ON
      SLOW_LOG: true
    published_ports:
      - 127.0.0.1:3306:3306
    log_driver: syslog
    log_options:
      tag: mariadb

/etc/logrotate.d/docker

/var/log/containers/*.log {
   daily
   rotate 10
   missingok
   compress
}