fix(docker): use non-blocking GELF delivery (#9317)

Docker's GELF driver now runs in non-blocking mode, so a listener outage
no longer blocks a container's log writes or skips the daemon's local log
copy. docker.md describes the default 1 MB delivery buffer and the live
console and CloudWatch Logs loss once it fills.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-11-23 22:19:17 -04:00
1 parent 99fa7b404e
commit d57fceb434
3 files changed
+5

No files matched your search

+2
View File
@@ -260,6 +260,8 @@ Docker opens that connection itself, from wherever the daemon runs, so the mode
The daemon's local copy of the log (dual logging, on by default since Docker Engine 20.10) is what `docker logs`, the RDS log-file APIs and the fallback below read, so keep it on; `log-max-size` and `log-max-file` bound it.
GELF delivery uses Docker's non-blocking mode so a listener outage does not block application log writes. Its per-container delivery buffer uses Docker's default size of `1m` (1 MB). When that buffer fills, Docker drops new messages: the live console and CloudWatch Logs streams are not lossless under sustained backpressure. Increasing the buffer only delays overflow. The local dual-log copy and polling fallback do not guarantee recovery of messages dropped before delivery, and `log-max-size` and `log-max-file` control local rotation, not this delivery buffer.
Docker keeps the listener's address in each container's log configuration and dials it every time the container starts, so the listener takes a fixed port, `log-driver-port` (12201, GELF's standard port), and Floci opens it before it starts any container. A stopped container that Floci adopts after a restart therefore starts again. The port must be free on Floci's host. A container created with another `log-driver-port` or `log-driver-host` keeps dialing the old address: Floci reads its log on a timer from the local copy and logs a warning, and once stopped it starts again only after the setting is restored or the resource is recreated.
`log-driver-host` overrides the host the daemon dials. When it names an address of Floci's own host (Floci's address on a Docker network, for example), the listener binds that address instead of loopback; the listener has no authentication beyond each container's random tag, so only point it at a network you trust:
@@ -118,6 +118,7 @@ public class GelfLogListener {
Map<String, String> options = new HashMap<>();
options.put("gelf-address", "tcp://" + ensureStarted());
options.put("tag", token);
options.put("mode", "non-blocking");
if (jsonFileOptions != null) {
copyOption(jsonFileOptions, "max-size", options, "cache-max-size");
copyOption(jsonFileOptions, "max-file", options, "cache-max-file");
@@ -121,6 +121,8 @@ class GelfLogListenerTest {
LogConfig logConfig = listener.logConfigFor("token-a", ROTATION);
assertEquals(LogConfig.LoggingType.GELF, logConfig.getType());
assertEquals("token-a", logConfig.getConfig().get("tag"));
assertEquals("non-blocking", logConfig.getConfig().get("mode"),
"failed GELF delivery must not skip the daemon's local copy");
assertEquals("10m", logConfig.getConfig().get("cache-max-size"), "the rotation bounds the daemon's copy");
assertEquals("3", logConfig.getConfig().get("cache-max-file"));
String address = logConfig.getConfig().get("gelf-address");