Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging to servlet in different docker image #19

Open
Mindtoeye opened this issue Apr 19, 2017 · 2 comments
Open

Logging to servlet in different docker image #19

Mindtoeye opened this issue Apr 19, 2017 · 2 comments

Comments

@Mindtoeye
Copy link

Mindtoeye commented Apr 19, 2017

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?

@ento
Copy link
Collaborator

ento commented Apr 19, 2017

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?)

@cosmo0920
Copy link
Member

cosmo0920 commented Nov 28, 2018

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants