title: Cannot access asp .net core app when run with docker on local machine, or to kubernetes
body: <p>I have a very simple asp.net core app (C# Web Application with Docker Support for Linux) and when i build the docker image and try to run it on my local PC the following happens;
  In docker with my image called test, i type docker run test, at which point it states "Content root path: /app Now listening on: <a href="http://[::]:80" rel="nofollow noreferrer">http://[::]:80</a>"
  And even though when i type docker ps i can see the process running, when i try to navigate to localhost:80 all i get is a long wait and then "This site can’t be reached, localhost refused to connect."</p>
  
  <p>I typed </p>
  
  <p><code>docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ec158cc3b344</code></p>
  
  <p>which gave me the containers IP address, but even navigating directly to the container i either get "This site can’t be reached
  " if i navigate on port 80, or "Your connection was interrupted" if i try to access the IP directly.</p>
  
  <p>I also tried to step over docker completely and deploy the image to Kubernetes to see if this would give me any luck, but instead when i try to access the services External-IP (In this case localhost), i get the following
  "This page isn’t working, localhost didn’t send any data."</p>
  
  <p>I also tried to use </p>
  
  <p><code>kubectl get pods -o wide</code></p>
  
  <p>and access the IP's of the pods directly, but this just gives me "This 10.1.0.32 page can’t be found", for example.</p>
  
  <p>And incase you're wondering, this is my dockerfile and kubernetes deployment .yml</p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
  WORKDIR /app
  EXPOSE 80
  
  FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
  WORKDIR /src
  COPY ["Test/Test.csproj", "Test/"]
  RUN dotnet restore "Test/Test.csproj"
  COPY . .
  WORKDIR "/src/Test"
  RUN dotnet build "Test.csproj" -c Release -o /app
  
  FROM build AS publish
  RUN dotnet publish "Test.csproj" -c Release -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "Test.dll"]
  </code></pre>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: test
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: test
    template:
      metadata:
        labels:
          app: test
      spec:
        containers:
        - name: test
          image: &lt;DockerEndpoint&gt;.io/test:v5 #Sorry, can't include the real endpoint!
          ports:
          - containerPort: 8080
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: test
  spec:
    type: LoadBalancer
    ports:
    - port: 80
      targetPort: 8080
    selector:
      app: test
  </code></pre>
  
  <p>I also understand that .net core work in weird way that don't allow it to expose its ports to the outside world unless you tell it to, but that combined with my relative newness to the docker/kubernetes stack and leaving me bewildered.</p>
  
  <p>Does anybody have any idea how i can make a .net core app, any app, work with docker?</p>
  
  <p>P.S. I am really using such a simple app that even if i create a brand new .net core app with docker support, and try to immediately build and run the basic .net core app, it doesnt work. i cannot make it work with literally any .net core app!</p>