From 161854e6d75cbd484796bdda455c23bf5f78fed7 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 26 Sep 2018 09:11:19 +0300 Subject: [PATCH] Disable Docker container logging `--log-driver=none` is used for all Docker containers now. All these containers are started through systemd anyway and get logged in journald, so there's no need for Docker to be logging the same thing using the default `json-file` driver. Doing that was growing `/var/lib/docker/containers/..` infinitely until service/container restart. As a result of this, things like `docker logs matrix-synapse` won't work anymore. `journalctl -u matrix-synapse` is how one can see the logs. --- CHANGELOG.md | 11 ++++++++ .../systemd/matrix-corporal.service.j2 | 1 + .../systemd/matrix-coturn.service.j2 | 1 + .../systemd/matrix-goofys.service.j2 | 25 ++++++++++--------- .../systemd/matrix-mailer.service.j2 | 1 + .../matrix-mautrix-telegram.service.j2 | 1 + .../templates/systemd/matrix-mxisd.service.j2 | 1 + .../systemd/matrix-nginx-proxy.service.j2 | 1 + .../systemd/matrix-postgres.service.j2 | 1 + .../systemd/matrix-riot-web.service.j2 | 1 + .../systemd/matrix-synapse.service.j2 | 1 + 11 files changed, 33 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a688911e..eb406b80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# 2018-09-26 + +## Disabling Docker container logging + +`--log-driver=none` is used for all Docker containers now. + +All these containers are started through systemd anyway and get logged in journald, so there's no need for Docker to be logging the same thing using the default `json-file` driver. Doing that was growing `/var/lib/docker/containers/..` infinitely until service/container restart. + +As a result of this, things like `docker logs matrix-synapse` won't work anymore. `journalctl -u matrix-synapse` is how one can see the logs. + + # 2018-09-17 ## Service discovery support diff --git a/roles/matrix-server/templates/systemd/matrix-corporal.service.j2 b/roles/matrix-server/templates/systemd/matrix-corporal.service.j2 index 2038bc98..25b02ad2 100644 --- a/roles/matrix-server/templates/systemd/matrix-corporal.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-corporal.service.j2 @@ -10,6 +10,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-corporal ExecStartPre=-/usr/bin/docker rm matrix-corporal ExecStart=/usr/bin/docker run --rm --name matrix-corporal \ + --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --network={{ matrix_docker_network }} \ {% if not matrix_nginx_proxy_enabled %} diff --git a/roles/matrix-server/templates/systemd/matrix-coturn.service.j2 b/roles/matrix-server/templates/systemd/matrix-coturn.service.j2 index 89cffa22..e598ea21 100644 --- a/roles/matrix-server/templates/systemd/matrix-coturn.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-coturn.service.j2 @@ -8,6 +8,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-coturn ExecStartPre=-/usr/bin/docker rm matrix-coturn ExecStart=/usr/bin/docker run --rm --name matrix-coturn \ + --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ -p 3478:3478 \ -p 3478:3478/udp \ diff --git a/roles/matrix-server/templates/systemd/matrix-goofys.service.j2 b/roles/matrix-server/templates/systemd/matrix-goofys.service.j2 index 2273e3ed..ef11d5c7 100644 --- a/roles/matrix-server/templates/systemd/matrix-goofys.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-goofys.service.j2 @@ -8,18 +8,19 @@ Type=simple ExecStartPre=-/usr/bin/docker kill %n ExecStartPre=-/usr/bin/docker rm %n ExecStart=/usr/bin/docker run --rm --name %n \ - --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ - -v /etc/passwd:/etc/passwd:ro \ - -v /etc/group:/etc/group:ro \ - --security-opt apparmor:unconfined \ - --cap-add mknod \ - --cap-add sys_admin \ - --device=/dev/fuse \ - -v {{ matrix_synapse_media_store_path }}:/s3:shared \ - --env-file={{ matrix_environment_variables_data_path }}/goofys \ - --entrypoint /bin/sh \ - {{ matrix_docker_image_goofys }} \ - -c 'goofys -f --storage-class=STANDARD_IA --region {{ matrix_s3_media_store_region }} --stat-cache-ttl 60m0s --type-cache-ttl 60m0s --dir-mode 0700 --file-mode 0700 {{ matrix_s3_media_store_bucket_name }} /s3' + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + -v /etc/passwd:/etc/passwd:ro \ + -v /etc/group:/etc/group:ro \ + --security-opt apparmor:unconfined \ + --cap-add mknod \ + --cap-add sys_admin \ + --device=/dev/fuse \ + -v {{ matrix_synapse_media_store_path }}:/s3:shared \ + --env-file={{ matrix_environment_variables_data_path }}/goofys \ + --entrypoint /bin/sh \ + {{ matrix_docker_image_goofys }} \ + -c 'goofys -f --storage-class=STANDARD_IA --region {{ matrix_s3_media_store_region }} --stat-cache-ttl 60m0s --type-cache-ttl 60m0s --dir-mode 0700 --file-mode 0700 {{ matrix_s3_media_store_bucket_name }} /s3' TimeoutStartSec=5min ExecStop=-/usr/bin/docker stop %n ExecStop=-/usr/bin/docker kill %n diff --git a/roles/matrix-server/templates/systemd/matrix-mailer.service.j2 b/roles/matrix-server/templates/systemd/matrix-mailer.service.j2 index 310d5502..c9eb040b 100644 --- a/roles/matrix-server/templates/systemd/matrix-mailer.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-mailer.service.j2 @@ -8,6 +8,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-mailer ExecStartPre=-/usr/bin/docker rm matrix-mailer ExecStart=/usr/bin/docker run --rm --name matrix-mailer \ + --log-driver=none \ --network={{ matrix_docker_network }} \ --env-file={{ matrix_environment_variables_data_path }}/env-mailer \ {{ matrix_docker_image_mailer }} diff --git a/roles/matrix-server/templates/systemd/matrix-mautrix-telegram.service.j2 b/roles/matrix-server/templates/systemd/matrix-mautrix-telegram.service.j2 index 99a47ee6..20a0bbc2 100644 --- a/roles/matrix-server/templates/systemd/matrix-mautrix-telegram.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-mautrix-telegram.service.j2 @@ -10,6 +10,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-mautrix-telegram ExecStartPre=-/usr/bin/docker rm matrix-mautrix-telegram ExecStart=/usr/bin/docker run --rm --name matrix-mautrix-telegram \ + --log-driver=none \ -e "UID={{ matrix_user_uid }}" -e "GID={{ matrix_user_gid }}" \ --network={{ matrix_docker_network }} \ -v {{ matrix_mautrix_telegram_base_path }}:/data:z \ diff --git a/roles/matrix-server/templates/systemd/matrix-mxisd.service.j2 b/roles/matrix-server/templates/systemd/matrix-mxisd.service.j2 index 637965c0..afbccbf0 100644 --- a/roles/matrix-server/templates/systemd/matrix-mxisd.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-mxisd.service.j2 @@ -12,6 +12,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-mxisd ExecStartPre=-/usr/bin/docker rm matrix-mxisd ExecStart=/usr/bin/docker run --rm --name matrix-mxisd \ + --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --network={{ matrix_docker_network }} \ {% if not matrix_nginx_proxy_enabled %} diff --git a/roles/matrix-server/templates/systemd/matrix-nginx-proxy.service.j2 b/roles/matrix-server/templates/systemd/matrix-nginx-proxy.service.j2 index ef5067f6..a1897943 100644 --- a/roles/matrix-server/templates/systemd/matrix-nginx-proxy.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-nginx-proxy.service.j2 @@ -18,6 +18,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-nginx-proxy ExecStartPre=-/usr/bin/docker rm matrix-nginx-proxy ExecStart=/usr/bin/docker run --rm --name matrix-nginx-proxy \ + --log-driver=none \ --network={{ matrix_docker_network }} \ -p 80:80 \ -p 443:443 \ diff --git a/roles/matrix-server/templates/systemd/matrix-postgres.service.j2 b/roles/matrix-server/templates/systemd/matrix-postgres.service.j2 index 1e619913..322961bf 100644 --- a/roles/matrix-server/templates/systemd/matrix-postgres.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-postgres.service.j2 @@ -10,6 +10,7 @@ ExecStartPre=-/usr/bin/docker rm matrix-postgres ExecStartPre=-/usr/bin/mkdir {{ matrix_postgres_data_path }} ExecStartPre=-/usr/bin/chown {{ matrix_user_uid }}:{{ matrix_user_gid }} {{ matrix_postgres_data_path }} ExecStart=/usr/bin/docker run --rm --name matrix-postgres \ + --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --network={{ matrix_docker_network }} \ --env-file={{ matrix_environment_variables_data_path }}/env-postgres-server-docker \ diff --git a/roles/matrix-server/templates/systemd/matrix-riot-web.service.j2 b/roles/matrix-server/templates/systemd/matrix-riot-web.service.j2 index d8e8d9be..36829936 100644 --- a/roles/matrix-server/templates/systemd/matrix-riot-web.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-riot-web.service.j2 @@ -8,6 +8,7 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-riot-web ExecStartPre=-/usr/bin/docker rm matrix-riot-web ExecStart=/usr/bin/docker run --rm --name matrix-riot-web \ + --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ -v {{ matrix_riot_web_data_path }}/config.json:/riot-web/webapp/config.json:ro \ -v {{ matrix_riot_web_data_path }}/riot.im.conf:/data/riot.im.conf:ro \ diff --git a/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 b/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 index 34ee8084..8b014a6d 100644 --- a/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 @@ -26,6 +26,7 @@ ExecStartPre=-/usr/bin/docker rm matrix-synapse ExecStartPre=/bin/sleep 5 {% endif %} ExecStart=/usr/bin/docker run --rm --name matrix-synapse \ + --log-driver=none \ --network={{ matrix_docker_network }} \ -p 8448:8448 \ {% if not matrix_nginx_proxy_enabled %}