1

I am struggling to get my docker container listening on localhost (keep getting site can't be reached). I have followed the official guides on jetbrains and some others I found around the net, but still having no luck.

On my local development I want my web API container and Postgres container to talk to each other, but when live the containers will be communicating with en RDS instance

DockerFile

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS base
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080

# Copy csproj and restore as distinct layers
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "api/api.csproj"
WORKDIR "/src/api"
RUN dotnet build "api.csproj" -c Release -o /app

FROM build AS publish
WORKDIR "/src/api"
RUN dotnet publish "api.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "api.dll", "--urls", "http://*:8080"]

LaunchSettings

  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:14317",
      "sslPort": 44301
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "wander.api": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "",
      "applicationUrl": "https://localhost:8081;http://localhost:8080",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

My Docker debug config My Docker debug config

My docker PS enter image description here

1 Answer 1

2

Pls share your docker run command. I am sure you specified -p option.

I am guessing it looks like below:

docker run <cotainer id> -p 57000:8080

8080 will be used from within docker container network.

From host machine you'll have access to the API using with 57000.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.