Home:ALL Converter>Cant access my Docker DotNet core website

Cant access my Docker DotNet core website

Ask Time:2016-07-03T03:30:12         Author:Kiksen

Json Formatter

I have run in to a dead end. I have a dotnet core 1.0.0 app I am trying to get up and running. It works great from linux and from windows. Now I am trying to get it into docker. I have made this docker file:

FROM microsoft/dotnet:1.0.0-preview2-sdk

COPY . /app
WORKDIR /app/app
RUN ["dotnet", "restore"]

ENTRYPOINT ["dotnet", "run"] 

It simply just copies code into app folder in docker image and restore dependencies and then runs it. When I try to run it, it starts up as everything is working and prints same as it was on windows or linux start up.

Docker Console

Command for running the project:

docker run --name dotNetWeb -p 8080:8080 kiksen1987/dotnetcore

Link to Code: https://github.com/kiksen1987/dotnetcore

Link to Docker image: https://hub.docker.com/r/kiksen1987/dotnetcore/

I really have no idea what is going wrong. I have more or less taking the same approach as 99% of my other projects.

Any feedback to improve this question would be nice aswell :)

Author:Kiksen,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/38163752/cant-access-my-docker-dotnet-core-website
Kiksen :

Finally.\n\nI found this blog post: http://dotnetliberty.com/index.php/2015/11/26/asp-net-5-on-aws-ec2-container-service-in-10-steps/\n\nEven though it used an old version of the dotnet core there was an important point I had overseen;\n\n\n Notice that I’ve provided an extra parameter to the dnx web command to tell it to serve on 0.0.0.0 (rather than the default localhost). This will allow our web application to serve requests that come in from the port forwarding provided by Docker which defaults to 0.0.0.0.\n\n\nWhich is pretty damn important.\n\nSolution:\n\nvar host = new WebHostBuilder()\n .UseKestrel()\n .UseStartup<Startup>()\n .UseUrls(\"http://0.0.0.0:5000\")\n .Build();\n\n\nOld code:\n\nvar host = new WebHostBuilder()\n .UseKestrel()\n .UseStartup<Startup>()\n .UseUrls(\"http://localhost:5000\")\n .Build();\n\n\nWhich is wery frustrating since it seemed to work perfect in Linux and windows and app starting up in Docker, but never getting any requests.\nHope this helps some other poor souls out there :)",
2016-07-02T21:27:50
mrbitzilla :

For newer .NET Core frameworks (such as 3.1 in this moment) this setting is on the launchSettings.json\n\n\"commandName\": \"Project\",\n \"launchBrowser\": true,\n \"applicationUrl\": \"https://localhost:5001;http://localhost:5000\",\n \"environmentVariables\": {\n \"ASPNETCORE_ENVIRONMENT\": \"Development\"\n",
2020-05-03T00:45:45
yy