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.
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 :)
Finally.
I found this blog post: http://dotnetliberty.com/index.php/2015/11/26/asp-net-5-on-aws-ec2-container-service-in-10-steps/
Even though it used an old version of the dotnet core there was an important point I had overseen;
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.
Which is pretty damn important.
Solution:
var host = new WebHostBuilder()
.UseKestrel()
.UseStartup<Startup>()
.UseUrls("http://0.0.0.0:5000")
.Build();
Old code:
var host = new WebHostBuilder()
.UseKestrel()
.UseStartup<Startup>()
.UseUrls("http://localhost:5000")
.Build();
Which is wery frustrating since it seemed to work perfect in Linux and windows and app starting up in Docker, but never getting any requests. Hope this helps some other poor souls out there :)
For newer .NET Core frameworks (such as 3.1 in this moment) this setting is on the launchSettings.json
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With