There could be multiple ways to get the logs from nginx to the logging agent in the container environment.
As this is quite an important decision I would like to describe some of the available options:
use nginx built-in syslog module to forward logs to the remote syslog
use docker built-in syslog logging driver to forward logs to the remote syslog
mount /var/log/nginx as docker data volume and attach that volume to the logging agent container
First option is the easiest to implement but it could also have the worst consequences.
By its design nginx will simply freeze when unable to write its logs in this case over syslog.
Second option seems rational as it will also allow us to get the logs from the Docker host itself.
Also it allows us to change logging driver from syslog to any other supported logging driver including fluentd.
However none of these two options require separate logging container.
Indeed we could forward the logs directly to the centralized logging server either from the nginx or the Docker host itself eliminating the need for an auxiliary logging container.
But as the separate logging agent is strictly required by the task I will proceed with the dedicated logging container option and storing nginx logs on a docker data volume.
There could be multiple ways to get the logs from nginx to the logging agent in the container environment.
As this is quite an important decision I would like to describe some of the available options:
First option is the easiest to implement but it could also have the worst consequences. By its design nginx will simply freeze when unable to write its logs in this case over syslog.
Second option seems rational as it will also allow us to get the logs from the Docker host itself. Also it allows us to change logging driver from syslog to any other supported logging driver including fluentd.
However none of these two options require separate logging container. Indeed we could forward the logs directly to the centralized logging server either from the nginx or the Docker host itself eliminating the need for an auxiliary logging container.
But as the separate logging agent is strictly required by the task I will proceed with the dedicated logging container option and storing nginx logs on a docker data volume.