Core: Can run using "dotnet run" but not with docker

Created on 11 Dec 2019  路  6Comments  路  Source: dotnet/core

I can run weatherforecast using port 5000 following tutorial.

However, I got connection refused when running from docker using this command:
docker run -it --rm -p 3000:80 --name mymicroservicecontainer mymicroservice

When I open "http://localhost:3000/WeatherForecast" I got connection refused. I try changing the port to 5000, still same. Is there something I need to do in docker setting?

I checked docker ps and it's running correctly there(port is same as I declared)

I follow tutorial step by step. All works well until running from docker

needs-more-info

Most helpful comment

This tutorial
https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/intro

I follow it step by step
When running "dotnet run" from this page, it works fine
https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/run

but when running using docker following this, it's not
https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/run-docker

All 6 comments

@eripin91 Can you tell us which tutorial you were following?

This tutorial
https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/intro

I follow it step by step
When running "dotnet run" from this page, it works fine
https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/run

but when running using docker following this, it's not
https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/run-docker

@carlossanlop I had attached the info, hope you can help me

It looks like you're trying to access through localhost. A docker image runs on a different IP, so you need to sub in whatever that is.

Closing due to lack of response; please re-open if you can provide more detail.

I'm having the same issue... According to the tutorial, you just have to enter localhost:3000/WeatherForecast but it just hangs... everything else works perfectly...

@scalablecory I am accessing through localhost... (note, i'm new to docker and normally build REST monolothic web api service... now trying to move to microservices)... (in case that influences your answer)...
@scalablecory "... you need to sub in whatever that is" ... what do you mean? where can I find that info...so I can sub it?

running on Windows 10... normal dev setup...

Was this page helpful?
0 / 5 - 0 ratings