Hi, for Consul registration I use:
registration = new AgentServiceRegistration()
{
ID = $"{serviceName}:{uri.Port}",
Name = $"{serviceName}",
Address = $"{uri.Host}",
Port = uri.Port
};
consulClient.Agent.ServiceDeregister(registration.ID).ConfigureAwait(true);
consulClient.Agent.ServiceRegister(registration).ConfigureAwait(true);
You can see, I need a uri and a port. In case of docker, this must be the external port, becuase other services should access the service via consul. I can't use the internal docker port, because it is internal and only "visible" for docker.
The question is, how I can get the internal port (value) and assign this value to registration .Port?