Docker Community Forums

Share and learn in the Docker community.

Using links in log options: No such host

(Matt Titmus) #1

Hi fellow Dockerteers,

Apologies if this has been asked before.

I’m trying to use the Gelf log driver to send data from a container to a linked Logstash instance living on the same server. However, when I do that the engine sends the following error that indicates the link is not known: “Failed to initialize logging driver: gelf: cannot connect to GELF endpoint: logstash:12201 dial udp: lookup logstash: no such host”

A simple test that demonstrates this is encapsulated in this docker-compose.yml:

image: httpd
- "80:80"
- "logstash:logstash"
log_driver: "gelf"
gelf-address: "udp://logstash:12201"

image: logstash
- "12201:12201"
- "12201:12201/udp"
- ./conf:/conf
command: logstash -f /conf/gelf.conf

However, if I specify the server name in the gelf-address everything works fine, but this breaks the portability of the composition.

Is this a bug or gotcha or am I doing something wrong? (The smart money’s on the latter)



(Matt Titmus) #2

As a followup, I tried abandoning the link idea and using a weave network. Although I could get the apache container to ping the logstash container, the plugin threw the same error.

Any help or guidance would be appreciated.

(Matt Titmus) #3

For any who may be interested, I found a solution, and it’s mind-bogglingly simple.

As it turns out (and is quite obvious in retrospect), the GELF log driver doesn’t use its container’s network stack; it uses the host’s. I haven’t tested the other drivers, but it may be the case with them as well.

As such, “localhost” can be used to refer to the running host in the log options: replacing reference to the “logstash” container with “localhost” in the gelf-address did the trick.

I hope this helps somebody.



(Spoluhub) #4

Thanks. It helped. Adding related issues:

Cannot paste direct link due to some silly restrictions…