I have a .NET 6 application. I start a Docker container, execute an http call to the container via HttpClient, then stop the container.
The code to stop the container does not run unless I comment out the PostAsync call.
//Start Container
var started = await dockerClient.Containers.StartContainerAsync(
containerId,
new ContainerStartParameters()
);
//Call To CodeExecution API
var result = await client.PostAsync("http://localhost:5000/CodeExecution", data);
string resultContent = result.Content.ReadAsStringAsync().Result;
runCodeResultModel = JsonConvert.DeserializeObject<RunCodeResultModel>(resultContent);
//Stop Container
await dockerClient.Containers.StopContainerAsync(
containerId,
new ContainerStopParameters
{
WaitBeforeKillSeconds = 15,
},
CancellationToken.None);