Search code examples
dockerlogginggrayloggelf

Docker logs with log-driver


I am running a new container using the following command:

docker run -d --log-driver=gelf --log-opt gelf-address=tcp://<my_log_server> nginx

Looking at the documentation, this should send the logs to my_log_server, and if I run the docker logs <my_container> command I shoult NOT see any logs. But actually I do, and I don't want this.

Do you have any idea why this is happening?

I'm testing it with Docker version 20.10.8, build 3967b7d


Solution

  • According to the docker documentation - https://docs.docker.com/config/containers/logging/configure/

    When using Docker Engine 19.03 or older, the docker logs command is only functional for the local, json-file and journald logging drivers. Docker 20.10 and up introduces “dual logging”, which uses a local buffer that allows you to use the docker logs command for any logging driver. Refer to reading logs when using remote logging drivers for details.

    Hope it clarifies.