fluent-plugin-out-http icon indicating copy to clipboard operation
fluent-plugin-out-http copied to clipboard

Logging to servlet in different docker image

Open Mindtoeye opened this issue 8 years ago • 2 comments

I have a FluentD docker image running your plugin and I have a docker image that runs a Wildfly microservice listening on port 8081. I'm trying to forward from the FluentD plugin to my servlet but the gem doesn't seem to use or resolve docker-compose network names properly. In my docker-compose file I have a service defined called 'logservice'. That service is configured with:

services:
  logservice:
    networks:
      - lognet

Then my network is configured as:

networks:
  lognet:
    driver: bridge

Other services can now contact docker images using the service name but the FluentD plugin doesn't work that way. I've tried the following configurations:

<match application.ags.**>
  type http
  endpoint_url    http://localhost.local:8081/logservice
  ...
<match application.ags.**>
  type http
  endpoint_url    http://logservice.local:8081/logservice
  ...
<match application.ags.**>
  type http
  endpoint_url    http://logservice:8081/logservice
  ...

I think (but am not sure) that I've fixed the name resolution part but the services are still not talking to each other. Forgot to add the actual console output for the configuration:

endpoint_url http://logservice:8081/logservice

I get the following output:

fluentd| 2017-04-19 13:16:46 +0000 [warn]: Net::HTTP.Put raises exception: Errno::ECONNREFUSED, 'Failed to open TCP connection to logservice:8081 (Connection refused - connect(2) for "logservice" port 8081)'

Any idea what might be going on?

Mindtoeye avatar Apr 19 '17 12:04 Mindtoeye

Now that fluentd is trying to connect to the (probably) correct service, it looks like the problem is on the logservice side. Only thing I can think of is to make sure the logservice definition in docker-compose.yaml specifies which ports to expose, like this. Also try attaching to any of the containers in the same lognet network and accessing logservice manually.

docker exec -it <container id> /bin/bash
# wget/curl http://logservice:8081/logservice
# or
# irb
# > require 'uri'
# > require 'net/http'
# > Net::HTTP.get_print URI.parse('http://logservice:8081/logservice')

If you can produce a minimum configuration I can use to replicate the problem, I can look into it further. or it might be quicker to ask on a docker community. (official forum? stack overflow?)

ento avatar Apr 19 '17 15:04 ento

Docker network does not resolve local DNS. Because Docker does not refer local DNS settings such as /etc/resolve.conf.

Could you try to get local DNS server IP address and specify into docker cli's --dns option?

$ nmcli dev show | grep 'IP4.DNS'
IP4.DNS[1]: brabra
$ docker run --dns brabra ...

ref: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

cosmo0920 avatar Nov 28 '18 06:11 cosmo0920