-
Notifications
You must be signed in to change notification settings - Fork 405
Open
Description
I'm on Windows, and I want to retrieve the exposed ports of the currently running ASP.NET Core MVC Linux image. The InspectContainerAsync method throws a System.Net.Http.HttpRequestException: 'Connection failed' error
SocketException: Cannot assign requested address
public static async Task<List<int>> GetExposedPorts()
{
var portsList = new List<int>();
var dockerClient = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")).CreateClient();
var dockerId = GetDockerId();
var containerInspect = await dockerClient.Containers.InspectContainerAsync(dockerId);
foreach (var port in containerInspect.NetworkSettings.Ports)
portsList.Add(int.Parse(port.Key));
return portsList;
}
The GetDockerId method returns the correct Docker ID, but I still can't inspect the container.
Here are the steps to reproduce: In Visual Studio 2022, create a new MVC project. Enable container support. Set the container OS to Linux. Set the container build type to Dockerfile. In the Debug menu, select 'Run in Container (Dockerfile).' Run the code provided above.
Metadata
Metadata
Assignees
Labels
No labels