Open dmitrime opened 8 years ago
Docker networking, hoorah! I'm afraid I'm not a docker user so can't help you. But, I would suggest doing some reading on how networking works in docker. It's not as straightforward as VMs.
@Moocar The thing is, I'm not even using docker! Like I said, the app is just copied to the home dir. It's true that the instance has docker installed, but my app is not using it, so I have no idea why it's choosing docker's IP...
ahh, right you are. I'm not sure what the issue would be. But it's most likely something that docker is doing on that machine. In case it helps, here's the code that gets the hostname: https://github.com/Moocar/logback-gelf/blob/master/src/main/java/me/moocar/logbackgelf/InternetUtils.java#L18
Ah, I think I see the problem there. It tries to take the first network interface, which happens to be the docker one.
NetworkInterface networkInterface = NetworkInterface.getNetworkInterfaces().nextElement();
// ...
InetAddress ipAddress = networkInterface.getInetAddresses().nextElement();
Would be nice to change it to prefer eth0
. However I already got around that by setting my own environment variable.
It's a bit strange that the correct $HOSTNAME
variable gets shadowed by that code, which overwrites it with an incorrect value. Why not just make a separate ${LOGBACK_HOSTNAME}
and keep the original $HOSTNAME
.
I have the following interfaces on a remote AWS machine:
My app however, is not using docker and is deployed by simply copying it to home directory and running from there. I set the host in logger.xml:
Now, I go to Graylog where I send my log messages and see docker's IP as the source: 172.17.0.1. Since all the instances that got docker running seem to have the same IP, I cannot really tell which instance is producing which messages! How can I get the
eth0
IP? Or identify the host in some other way?