Can I use the system default docker logger?

I am trying to consume build logs into our logging infrastructure by configuring our docker runners to use the loki docker driver. Installing that as the system default causes all new containers to log to our loki instance.

But build containers are explicitly created to use the json-file logger, no matter what.

I can sort-of see why that is a sensible choice, you need to make sure docker logs works to get the output. But in our case, the json files are still created, and everything will still work as needed.

I’d love to get a patch to allow customization here, but not sure the best approach:

  1. Don’t set the log config at all, and always use the system default. Easiest, but possibly users would run into problems if they change the host’s driver without knowing the consequences (probably rare).
  2. Have some runner variable to activate the above as an override to the current behaviour.
  3. Some kind of config in the step? I’d rather not need that, since our goal is to get all logs in one place.

I’d probably prefer option 1, but I am not sure why this is set in the first place. I imagine there is some historical reason for it.

I’d probably prefer option 1, but I am not sure why this is set in the first place. I imagine there is some historical reason for it.

The reason is because that you could not use docker logs with custom logging drivers. This prevented Drone from using the Docker remote API to get the build logs to display in the user interface and would result in empty logs (issue #1523) due to an error from the docker daemon:

The docker logs command was not available for drivers other than json-file and gelf.

The docker Community Edition does not support docker logs for the majority of docker logging drivers. The docker Enterprise Edition does, however, support dual logging since version 18.03. The downside is this only works with the enterprise edition.

When using Docker Community Engine, the docker logs command is only available on the following drivers:

  • local
  • json-file
  • journald
  1. Have some runner variable to activate the above as an override to the current behaviour.

This would be the desired approach to avoid any breaking changes for teams running older version of the docker daemon, as well as teams running the docker community edition.

Thanks for your reply. That makes sense. I will make a pull request to that effect.