I have a .netcore 3.1 api app created with the default WeatherForecast Controller in it. I have created the Dockerfile which looks like the below:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /build
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o output
FROM mcr.microsoft.com/dotnet/core/sdk:3.1
WORKDIR /app
EXPOSE 5000
COPY --from=build-env /build/output .
ENTRYPOINT ["dotnet","AnotherSampleDockerExample.dll"]
Also I have the docker-compose.yml which looks like below:
version : '3'
services:
api:
image: dockerapi
container_name: docker_api
build:
context: .
ports:
- 8080:80
I am able to successfully create the image and the container by using the command "docker-compose up". But when I try to access it on the Chrome Browser with http://localhost:5000/WeatherForecast, the browser returns
"This site can’t be reached
localhost refused to connect." error.
Need help here to debug this issue. Thanks!