From e3dca2f66f10b384d36d91f1dc29c278ef14db8a Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 1 Sep 2020 09:03:06 +0300 Subject: [PATCH] Try to avoid Docker logs growing too much for one-off containers We recently had a report of the Postgres backup container's log file growing the size of /var/lib/docker until it ran out of disk space. Trying to prevent similar problems in the future. --- docs/maintenance-postgres.md | 1 + roles/matrix-postgres/tasks/import_postgres.yml | 1 + roles/matrix-postgres/tasks/import_sqlite_db.yml | 1 + roles/matrix-postgres/tasks/upgrade_postgres.yml | 2 ++ 4 files changed, 5 insertions(+) diff --git a/docs/maintenance-postgres.md b/docs/maintenance-postgres.md index 6f599de1..d385bc9c 100644 --- a/docs/maintenance-postgres.md +++ b/docs/maintenance-postgres.md @@ -42,6 +42,7 @@ To make a back up of the current PostgreSQL database, make sure it's running and ```bash docker run \ --rm \ +--log-driver=none \ --network=matrix \ --env-file=/matrix/postgres/env-postgres-psql \ postgres:12.4-alpine \ diff --git a/roles/matrix-postgres/tasks/import_postgres.yml b/roles/matrix-postgres/tasks/import_postgres.yml index e58711f1..0753c292 100644 --- a/roles/matrix-postgres/tasks/import_postgres.yml +++ b/roles/matrix-postgres/tasks/import_postgres.yml @@ -64,6 +64,7 @@ set_fact: matrix_postgres_import_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-import + --log-driver=none --user={{ matrix_user_uid }}:{{ matrix_user_gid }} --cap-drop=ALL --network={{ matrix_docker_network }} diff --git a/roles/matrix-postgres/tasks/import_sqlite_db.yml b/roles/matrix-postgres/tasks/import_sqlite_db.yml index 850ee370..fe0deba8 100644 --- a/roles/matrix-postgres/tasks/import_sqlite_db.yml +++ b/roles/matrix-postgres/tasks/import_sqlite_db.yml @@ -74,6 +74,7 @@ docker run --rm --name=matrix-synapse-migrate + --log-driver=none --user={{ matrix_user_uid }}:{{ matrix_user_gid }} --cap-drop=ALL --network={{ matrix_docker_network }} diff --git a/roles/matrix-postgres/tasks/upgrade_postgres.yml b/roles/matrix-postgres/tasks/upgrade_postgres.yml index 73263695..c1a01d3f 100644 --- a/roles/matrix-postgres/tasks/upgrade_postgres.yml +++ b/roles/matrix-postgres/tasks/upgrade_postgres.yml @@ -80,6 +80,7 @@ - name: Perform Postgres database dump command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-dump + --log-driver=none --user={{ matrix_user_uid }}:{{ matrix_user_gid }} --network={{ matrix_docker_network }} --env-file={{ matrix_postgres_base_path }}/env-postgres-psql @@ -124,6 +125,7 @@ set_fact: matrix_postgres_import_command: >- {{ matrix_host_command_docker }} run --rm --name matrix-postgres-import + --log-driver=none --user={{ matrix_user_uid }}:{{ matrix_user_gid }} --cap-drop=ALL --network={{ matrix_docker_network }}