-
-
Notifications
You must be signed in to change notification settings - Fork 104
Closed
Labels
enhancementunder-investigationA investigation is made around the issueA investigation is made around the issuewaiting-for-feedbackWaiting for someone to give feedback until this issue can be brought further.Waiting for someone to give feedback until this issue can be brought further.
Milestone
Description
Hey there, huge fan of the library! Very well done.
Wondering if it would be possible to expose the host ports for a container? I'm able to get the exposed ports, but not the host ones.
For example, if i did this:
var container = new Builder().UseContainer()
.WithName("MyName")
.UseImage($"{DB_IMAGE}:{DB_IMAGE_TAG}")
.ExposePort(freePort, 5432)
.WithEnvironment(
"POSTGRES_PASSWORD={DB_PASSWORD}",
$"POSTGRES_DB={DB_NAME}",
$"POSTGRES_PASSWORD={DB_PASSWORD}")
.WaitForPort("5432/tcp", 30000 /*30s*/)
.MountVolume(volume, "/var/lib/postgresql/data", MountType.ReadWrite)
.Build();I'd like to be able to get the port for that container with something along the lines of this or whatever else makes sense
var docker = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default");
var existingContainer = docker?.GetContainers().FirstOrDefault(c => c.Name == DB_CONTAINER_NAME);
// this should return whatever `freePort` was from above
var ports = existingContainer.GetConfiguration().Config.HostPorts.FirstOrDefault();Metadata
Metadata
Assignees
Labels
enhancementunder-investigationA investigation is made around the issueA investigation is made around the issuewaiting-for-feedbackWaiting for someone to give feedback until this issue can be brought further.Waiting for someone to give feedback until this issue can be brought further.