I’ve found this as well, it seems nginx is failing to rotate the log. Googling has told me it’s likely due to permission issues on the log file itself but I haven’t been able to work out exactly what is happening.
Our forum just crashed due to no free disk space. It was caused by a 5GB /var/log/nginx/access.log.1 as described above.
Is this something that is fixed if I pull and rebuild the image?
Details:
I had an extra 5GB log file on the “physical” server too (from the world accessible nginx server which proxies to the Docker image) and I’ve solved the problem there by updating the logrotate config to force a rotation if the log file exceeds 100MB and running logrotate manually.
I’m not really sure how to solve this on the docker instance though. If I were to edit the logrotate config, would it be overwritten when I update Discourse?
I think I’d just like to add size 100M to the file /etc/logrotate.d/nginx. This would cause the file to be rotated every day or when it reaches 100M (whichever comes first), as long as logrotate is being called often enough to notice the file is >100M.
danny:/var/docker$ ./launcher ssh app
Warning: Permanently added '[0.0.0.0]:2222' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.2.0-54-generic x86_64)
* Documentation: https://help.ubuntu.com/
root@discourse:~# cd /var/log/nginx
root@discourse:/var/log/nginx# ls -lahS
total 5.1G
-rw-r----- 1 www-data adm 5.1G Apr 10 14:04 access.log.1
-rw-r--r-- 1 root root 20M Mar 7 04:00 access.log.2.gz
-rw-r--r-- 1 root root 52K Mar 6 16:53 error.log.1
-rw-r----- 1 www-data adm 41K Apr 10 13:37 error.log
drwxr-x--- 2 www-data adm 4.0K Mar 7 05:11 .
drwxrwxr-x 11 root syslog 4.0K Apr 10 14:04 ..
-rw-r----- 1 www-data adm 0 Mar 7 05:11 access.log
root@discourse:/var/log/nginx# cat /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
invoke-rc.d nginx rotate >/dev/null 2>&1
endscript
}