-
Notifications
You must be signed in to change notification settings - Fork 163
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
Register Docker Application in Eureka with "preferIpAddress": true #11
Comments
I found that application get registered in Eureka with the docker container IP rather than the IP I have used in the configuration. |
@Isuama : https://github.com/SteeltoeOSS/Samples/tree/dev/Discovery/src/AspDotNetCoreDocker Hope that helps. Dave |
Thank you @dtillman. I guess what you have done was, exposing the same port inside the docker container and consuming the same port from outside. |
If you need to control what is registered in eureka, then you can set registrationMethod=hostName and then put a value in the hostName setting (DNS or IP address). That is what will end up getting registered in the eureka server and ultimately retrieved and used by the client. As a FYI, in the sample I used docker-compose (DC) to run the FORTUNE-TELLER-UI, the FORTUNE-TELLER-SERVICE, and the Eureka server ( I just used a standard VS2017 project with Docker compose enabled). DC creates a network with all those services running with-in it and makes networking very easy so you don't have to worry about the details. The DC network has a built-in hostname resolution service so all the registration/lookup happens on the DC network using names and addresses defined there. I also exposed each of the services(UI, eureka, etc) to the host using port mapping so you can access each container from a browser on the host. I probably could have not exposed the F-T-Service to the host since the communications from the UI to the F-T-Services is done on the DC network...but I elected to do so for testing. Let me know if the above "hostName" doesn't work for you! Doc Link for registrationMethod |
I also encountered the same problem. |
Dear Dave, Could you please explain then why they have a property like preferIpAddress and ipAddress. As per my understanding if we set preferIpAddress =true and set an IP it should work, isn't it. But trust me, It doesn't work. |
This is worth investigating further and trying to address in a later release. |
I'm pretty confident this works as expected, after #1280 has been merged. I've added a test to verify: [Fact]
public async Task ExplicitlyConfiguredIPAddressIsPreserved()
{
var appSettings = new Dictionary<string, string?>
{
["Eureka:Instance:hostName"] = "ignored-host-name",
["Eureka:Instance:ipAddress"] = "192.168.10.20",
["Eureka:Instance:preferIpAddress"] = "true"
};
WebApplicationBuilder builder = WebApplication.CreateBuilder();
builder.Configuration.AddInMemoryCollection(appSettings);
builder.Services.AddEurekaDiscoveryClient();
await using WebApplication webApplication = builder.Build();
var appManager = webApplication.Services.GetRequiredService<EurekaApplicationInfoManager>();
appManager.Instance.IPAddress.Should().Be("192.168.10.20");
appManager.Instance.HostName.Should().Be("192.168.10.20");
} Please let me know if this is still causing problems. |
When I register application in IIS and point it to Eureka as shown in this sample, it properly works with these parameters in appsetting.json.
"eureka": {
"client": {
"serviceUrl": "http://172.15.100.155:8761/eureka/",
"shouldFetchRegistry": false
},
"instance": {
"port": 8091,
"hostName": "fortune_service",
"ipAddress": "http://172.15.100.11",
}
When I point cursor over the Eureka Status it shows me the status url (IP I have given above)
But when I run application as a Docker and retrieve value from Confi-Server, it get registered with a dynamic IP for the status and I am unable to discover registered URL. Kindly expect help from someone.
The text was updated successfully, but these errors were encountered: