Niels Sparenberg
Niels Sparenberg

Reputation: 141

Can't connect to ASP.NET core through docker

Hi people have been looking at this for far too long and need some help.

I have made a ASP.NET core website nothing fancy just the template that goes with VS 2017 (v 1.1). I publish the site using dotnet core cli and build an image using this dockerfile:

FROM microsoft/dotnet:1.1-runtime
COPY /Publish /dotnetapp
WORKDIR /dotnetapp

EXPOSE 8444
ENTRYPOINT ["dotnet", "Inqu.dll"]

When i run the image created with:

docker run -it <image_name:tag> -p 8444:8444

The image starts up waiting for request:

Hosting environment: Production
Content root path: /dotnetapp
Now listening on: http://*:8444
Application started. Press Ctrl+C to shut down.

but i can't reach the site and getting an ERR_CONNECTION_REFUSED when trying to access the site thought http://local-ip:8444/

I have modified the WebHostBuild to:

        var host = new WebHostBuilder()
            .UseKestrel()
            .UseUrls("http://*:8444")
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseStartup<Startup>()
            .UseApplicationInsights()
            .Build();

        host.Run();

So it should listen to port 8444, I have also tried to set:

ENV ASPNETCORE_URLS http://*:8444

in the Dockerfile but it doesnt help.


I have some other images in docker up and running (gogs and mysql) and i can access them with my local ip:port with no problems, but i can't connect to the kestrel server.

Can somebody please help me out?

Upvotes: 2

Views: 2339

Answers (1)

Niels Sparenberg
Niels Sparenberg

Reputation: 141

Was a stupid mistake arguments were in wrong order

docker run -it -p 8444:8444 <image_name:tag>

and it worked :\

Upvotes: 9

Related Questions