[infra] Limit the maximum size of the nginx stdout logs

nginx logs to stdout, which is captured by docker and put into a file at
/var/lib/docker/containers/<nginx-cont-id>/<id>-json.log

By default, the size of this file is unbounded. Add a maximum limit of 1 GB to this.

References:
- https://docs.docker.com/config/containers/logging/local/
- https://stackoverflow.com/questions/31829587/docker-container-logs-taking-all-my-disk-space
This commit is contained in:
Manav Rathi 2024-04-10 09:23:48 +05:30
parent 13a78ce84a
commit e2c894f87f
No known key found for this signature in database

View file

@ -16,5 +16,6 @@ ExecStart=docker run --name nginx \
-v /root/nginx/cert.pem:/etc/ssl/certs/cert.pem:ro \ -v /root/nginx/cert.pem:/etc/ssl/certs/cert.pem:ro \
-v /root/nginx/key.pem:/etc/ssl/private/key.pem:ro \ -v /root/nginx/key.pem:/etc/ssl/private/key.pem:ro \
-v /root/nginx/conf.d:/etc/nginx/conf.d:ro \ -v /root/nginx/conf.d:/etc/nginx/conf.d:ro \
--log-opt max-size=1g \
nginx nginx
ExecReload=docker exec nginx nginx -s reload ExecReload=docker exec nginx nginx -s reload