title: Docker: Cannot launch .Net Core 3.1 Web Api on browser after docker run
body: <p>I'm new to Docker and, as a start, I'm trying to accomplish a basic task, dockerize a .Net Core 3.1 Web Api and run it from the command line (not From Visual Studio where it actually works).</p>
  
  <p>I create my project image using the following Dockerfile and with the next command:</p>
  
  <pre><code>docker build -t concepttest_crud1 .
  </code></pre>
  
  <p>Dockerfile (created by Visual Studio):</p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
  WORKDIR /app
  EXPOSE 80
  EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
  WORKDIR /src
  COPY ["Gfi_ConceptTest_CRUD1/Gfi_ConceptTest_CRUD1.csproj", "Gfi_ConceptTest_CRUD1/"]
  RUN dotnet restore "Gfi_ConceptTest_CRUD1/Gfi_ConceptTest_CRUD1.csproj"
  COPY . .
  WORKDIR "/src/Gfi_ConceptTest_CRUD1"
  RUN dotnet build "Gfi_ConceptTest_CRUD1.csproj" -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish "Gfi_ConceptTest_CRUD1.csproj" -c Release -o /app/publish
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT ["dotnet", "Gfi_ConceptTest_CRUD1.dll"]
  </code></pre>
  
  <p>4) I run my image with the following command:</p>
  
  <pre><code>docker run -d -p 8080:44390 --name crud1 concepttest_crud1
  </code></pre>
  
  <p>where 44390 is the port I have my api configured on in Visual Studio.</p>
  
  <p>When debugging I use to access the api through:</p>
  
  <pre><code>https://localhost:44390/api/Authors
  </code></pre>
  
  <p>5) I'm trying to test my dockerized api in Chrome with the next url:</p>
  
  <pre><code>https://localhost:8080/api/Authors
  </code></pre>
  
  <p>to no avail. No matter with url I try, my api won't start when the docker run command executes with no errors.</p>
  
  <p>docker ps output:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
  8df6c92c6678        concepttest_crud1   "dotnet Gfi_ConceptT…"   22 minutes ago      Up 22 minutes       0.0.0.0:8080-&gt;44390/tcp   crud1
  </code></pre>
  
  <p>docker images output:</p>
  
  <pre><code>REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
  concepttest_crud1                      latest              878e4c4845f6        About an hour ago   228MB
  &lt;none&gt;                                 &lt;none&gt;              36a29990113c        About an hour ago   1GB
  </code></pre>
  
  <p>In the Docker images output I don't know why I see two images (a second with no name) when I expect only one.</p>
  
  <p>I've also tried <a href="http://192.168.99.100:8080/api/Authors" rel="nofollow noreferrer">http://192.168.99.100:8080/api/Authors</a> but it is not working either.</p>
  
  <p>Edit 1: Adding docker inspect.</p>
  
  <pre><code>[
      {
          "Id": "0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57",
          "Created": "2019-12-23T12:30:06.3947619Z",
          "Path": "dotnet",
          "Args": [
              "Gfi_ConceptTest_CRUD1.dll"
          ],
          "State": {
              "Status": "running",
              "Running": true,
              "Paused": false,
              "Restarting": false,
              "OOMKilled": false,
              "Dead": false,
              "Pid": 83477,
              "ExitCode": 0,
              "Error": "",
              "StartedAt": "2019-12-23T12:30:08.9701219Z",
              "FinishedAt": "0001-01-01T00:00:00Z"
          },
          "Image": "sha256:92b9217abf5dc6a7fc6c10aac2ac5549d6873adfc1b3ed30264d6e1fd4a971c7",
          "ResolvConfPath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/resolv.conf",
          "HostnamePath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/hostname",
          "HostsPath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/hosts",
          "LogPath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57-json.log",
          "Name": "/crud1",
          "RestartCount": 0,
          "Driver": "overlay2",
          "Platform": "linux",
          "MountLabel": "",
          "ProcessLabel": "",
          "AppArmorProfile": "",
          "ExecIDs": null,
          "HostConfig": {
              "Binds": null,
              "ContainerIDFile": "",
              "LogConfig": {
                  "Type": "json-file",
                  "Config": {}
              },
              "NetworkMode": "default",
              "PortBindings": {
                  "443/tcp": [
                      {
                          "HostIp": "",
                          "HostPort": "8080"
                      }
                  ]
              },
              "RestartPolicy": {
                  "Name": "no",
                  "MaximumRetryCount": 0
              },
              "AutoRemove": false,
              "VolumeDriver": "",
              "VolumesFrom": null,
              "CapAdd": null,
              "CapDrop": null,
              "Capabilities": null,
              "Dns": [],
              "DnsOptions": [],
              "DnsSearch": [],
              "ExtraHosts": null,
              "GroupAdd": null,
              "IpcMode": "private",
              "Cgroup": "",
              "Links": null,
              "OomScoreAdj": 0,
              "PidMode": "",
              "Privileged": false,
              "PublishAllPorts": false,
              "ReadonlyRootfs": false,
              "SecurityOpt": null,
              "UTSMode": "",
              "UsernsMode": "",
              "ShmSize": 67108864,
              "Runtime": "runc",
              "ConsoleSize": [
                  28,
                  165
              ],
              "Isolation": "",
              "CpuShares": 0,
              "Memory": 0,
              "NanoCpus": 0,
              "CgroupParent": "",
              "BlkioWeight": 0,
              "BlkioWeightDevice": [],
              "BlkioDeviceReadBps": null,
              "BlkioDeviceWriteBps": null,
              "BlkioDeviceReadIOps": null,
              "BlkioDeviceWriteIOps": null,
              "CpuPeriod": 0,
              "CpuQuota": 0,
              "CpuRealtimePeriod": 0,
              "CpuRealtimeRuntime": 0,
              "CpusetCpus": "",
              "CpusetMems": "",
              "Devices": [],
              "DeviceCgroupRules": null,
              "DeviceRequests": null,
              "KernelMemory": 0,
              "KernelMemoryTCP": 0,
              "MemoryReservation": 0,
              "MemorySwap": 0,
              "MemorySwappiness": null,
              "OomKillDisable": false,
              "PidsLimit": null,
              "Ulimits": null,
              "CpuCount": 0,
              "CpuPercent": 0,
              "IOMaximumIOps": 0,
              "IOMaximumBandwidth": 0,
              "MaskedPaths": [
                  "/proc/asound",
                  "/proc/acpi",
                  "/proc/kcore",
                  "/proc/keys",
                  "/proc/latency_stats",
                  "/proc/timer_list",
                  "/proc/timer_stats",
                  "/proc/sched_debug",
                  "/proc/scsi",
                  "/sys/firmware"
              ],
              "ReadonlyPaths": [
                  "/proc/bus",
                  "/proc/fs",
                  "/proc/irq",
                  "/proc/sys",
                  "/proc/sysrq-trigger"
              ]
          },
          "GraphDriver": {
              "Data": {
                  "LowerDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291-init/diff:/var/lib/docker/overlay2/025232b693c4a6470e0b26e5302e5165757dbc4a44d5af5b7b8aa8dacd77ee03/diff:/var/lib/docker/overlay2/bcca2356fe199bbaa471c3590a3f55df343eecd84899cf570197d97ed8111d95/diff:/var/lib/docker/overlay2/5f2d77acbd50bc4a8cde011128fb43b2a0cff888e716c5ba882d4dd906bc1901/diff:/var/lib/docker/overlay2/ca57ac72ac1d48b622745bb473fd71c18d67392b02cdf938835f05cf9b547681/diff:/var/lib/docker/overlay2/0b894b31b26df6e40b57a86dc66bbd4eda71d0ebf6d5755c4c43bc296e9a24de/diff:/var/lib/docker/overlay2/b6ca0109d2718605ccba2585e52ae1718cbecd2fcd62197f1f7fd505cf2be358/diff:/var/lib/docker/overlay2/e0ff62d02fe725053674ce9e3b59a4004c101fd2e98f919e5037a412f1c3a4e8/diff",
                  "MergedDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291/merged",
                  "UpperDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291/diff",
                  "WorkDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291/work"
              },
              "Name": "overlay2"
          },
          "Mounts": [],
          "Config": {
              "Hostname": "0f0bf4b4de30",
              "Domainname": "",
              "User": "",
              "AttachStdin": false,
              "AttachStdout": false,
              "AttachStderr": false,
              "ExposedPorts": {
                  "443/tcp": {},
                  "8080/tcp": {}
              },
              "Tty": true,
              "OpenStdin": false,
              "StdinOnce": false,
              "Env": [
                  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                  "ASPNETCORE_URLS=http://+:80",
                  "DOTNET_RUNNING_IN_CONTAINER=true"
              ],
              "Cmd": null,
              "Image": "crud1",
              "Volumes": null,
              "WorkingDir": "/app",
              "Entrypoint": [
                  "dotnet",
                  "Gfi_ConceptTest_CRUD1.dll"
              ],
              "OnBuild": null,
              "Labels": {}
          },
          "NetworkSettings": {
              "Bridge": "",
              "SandboxID": "ed889f3303ca17ad4e79ae917d8b17c5e590af502adb8049dbd7e0fcd46b323c",
              "HairpinMode": false,
              "LinkLocalIPv6Address": "",
              "LinkLocalIPv6PrefixLen": 0,
              "Ports": {
                  "443/tcp": [
                      {
                          "HostIp": "0.0.0.0",
                          "HostPort": "8080"
                      }
                  ],
                  "8080/tcp": null
              },
              "SandboxKey": "/var/run/docker/netns/ed889f3303ca",
              "SecondaryIPAddresses": null,
              "SecondaryIPv6Addresses": null,
              "EndpointID": "001cd49640c4211e5eeb1eedacedd6de07022cc3362acaca59b82f0e537f6238",
              "Gateway": "172.17.0.1",
              "GlobalIPv6Address": "",
              "GlobalIPv6PrefixLen": 0,
              "IPAddress": "172.17.0.2",
              "IPPrefixLen": 16,
              "IPv6Gateway": "",
              "MacAddress": "02:42:ac:11:00:02",
              "Networks": {
                  "bridge": {
                      "IPAMConfig": null,
                      "Links": null,
                      "Aliases": null,
                      "NetworkID": "ccea227190a1f04d0043015cf3d9932ba41f4a96dfb9bc2a175a06483a9ca66e",
                      "EndpointID": "001cd49640c4211e5eeb1eedacedd6de07022cc3362acaca59b82f0e537f6238",
                      "Gateway": "172.17.0.1",
                      "IPAddress": "172.17.0.2",
                      "IPPrefixLen": 16,
                      "IPv6Gateway": "",
                      "GlobalIPv6Address": "",
                      "GlobalIPv6PrefixLen": 0,
                      "MacAddress": "02:42:ac:11:00:02",
                      "DriverOpts": null
                  }
              }
          }
      }
  ]
  </code></pre>
  
  <p>Edit 2: Added curl.</p>
  
  <pre><code>docker exec -it 0f0bf4b4de30 /bin/bash . root@4237f947b2b0:/app# curl https://localhost:8080/api/Authors
  
  .: .: Is a directory
  </code></pre>
  
  <p>Edit 3: New curl</p>
  
  <pre><code>docker exec -it 0f0bf4b4de30 /bin/bash . root@4237f947b2b0:/app# curl https://localhost/api/Authors
  .: .: Is a directory
  </code></pre>