WaitForPort using custom address
It is now possible to use WaitForPort
with an optional argument address. If it is not supplied, the old behaviour of doing inspect
on the container and grab the network settings is used. However, if it is supplied it will replace the IP address with the supplied one (still resolve the port).
using (var c = Fd.UseContainer()
.WithName("profiles-smtp-server")
.UseImage("mailhog/mailhog:latest")
.ReuseIfExists()
.ExposePort(5011, 8025)
.ExposePort(1025)
.WaitForPort("8025/tcp", TimeSpan.FromSeconds(30), "127.0.0.1")
.Build())
{
c.Start();
var port = c.ToHostExposedEndpoint("8025/tcp").Port;
var response = $"http://127.0.0.1:{port}/".Wget().Result;
IsTrue(response.IndexOf("<title>MailHog</title>", StringComparison.Ordinal) != -1);
}
The above example will use the 127.0.0.1 as the address (loopback) when communicating with port 5011. This helps to solve the Issue #92.
Cheers,
Mario