From 375e7b9ce420f403faccae6dd38ecde341525989 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Tue, 2 May 2017 01:38:43 +0000 Subject: [PATCH 1/2] Add rotation feature to docker logs --- files/build_templates/docker_image_ctl.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 3df04b698ccb..06a3d9e61730 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -11,6 +11,7 @@ start() { else docker run -d {{docker_image_run_opt}} \ + --log-opt max-size=2M --log-opt max-file=5 \ -v /var/run/redis:/var/run/redis:rw \ -v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \ -v /usr/share/sonic/device/$PLATFORM/$HWSKU:/usr/share/sonic/hwsku:ro \ From 01840fa4716040a46579d638e02b951bb2f5b6f7 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Tue, 2 May 2017 06:34:07 +0000 Subject: [PATCH 2/2] Fix: only apply log rotation for json-file log driver --- files/build_templates/docker_image_ctl.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 06a3d9e61730..9a1f79c4ed5a 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -11,7 +11,9 @@ start() { else docker run -d {{docker_image_run_opt}} \ +{%- if '--log-driver=json-file' in docker_image_run_opt or '--log-driver' not in docker_image_run_opt %} --log-opt max-size=2M --log-opt max-file=5 \ +{%- endif %} -v /var/run/redis:/var/run/redis:rw \ -v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \ -v /usr/share/sonic/device/$PLATFORM/$HWSKU:/usr/share/sonic/hwsku:ro \