3

I have searched about this but cannot find a solution... I have a .NET Core web api project and containerized it inside the docker. My host for docker is a VM in VirtualBox with CentOS 7.5. I run the container using the command:

docker run -d -name webapi -p 80:5000 netcorelnx

I can then by using the command:

docker exec -ti webapi /bin/bash

Get to that container and execute inside it:

curl localhost:5000/api/values

This returns the correct values returned by my .NET Core web api project. However when I am trying to call this from my host's browser by using the url http://localhost/api/values it says "The connection was reset". This is my dockerfile:

...
FROM microsoft/dotnet:2.1-aspnetcore-runtime-bionic AS runtime
...
ENV ASPNETCORE_URLS http://+:5000
ENTRYPOINT["dotnet", "NetCoreWebApi.dll"]

What is wrong?

1 Answer 1

4

As usual after many hours of investigations and posting a question I have found out a solution. The problem was in the code of the .NET core app which has been not written by me. There was a line:

.UseKestrel(options => { options.Listen(IPAddress.Loopback, 5000); });

Instead of

.UseKestrel(options => { options.Listen(IPAddress.Any, 5000); });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.