Search code examples
dockernano-server

Unable to access Docker Nanoserver container web app


This question is similar to others on the topic of Windows networks and how they relate to Docker containers, but I can't seem to find a solution to my exact problem.

I am setting up a Docker container for a new pre-build pre-published .NET Core 1.1 application. I have a Dockerfile which builds the app into a nanoserver/.NET Core 1.1 enabled image, yet I am NOT able to access the running application from the Windows host.

Using: Docker for Windows 17.0.31-ce-win10 (11972) on a Windows 10 Pro VM hosted by macOS/vmWare Fusion 8.5.1.

Given the following Dockerfile:

FROM microsoft/dotnet:1.1-runtime-nanoserver WORKDIR \app COPY \out . EXPOSE 80 EXPOSE 5000 ENTRYPOINT ["dotnet", "WebApi.dll"]

If I use the command docker run {image} -P 5000:5000 I get the following output (from a .NET Core 1.1 Hello World app):

Hosting environment: Production Content root path: C:\app Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down.

Then, in another terminal window, I issue the following command:

docker inspect {container-name} where I get this notable output:

"Networks": { "nat": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "246469d0fe2936d87c5a923 "EndpointID": "2401e38f20539ac9fe562e "Gateway": "172.20.64.1", "IPAddress": "172.20.76.30", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "00:15:5d:33:3e:7a" } }

I'm not able to access the web application using the following locations:

localhost:5000, 172.20.76.30:80, 172.20.76.30:5000

Curiously, however, if I docker run microsoft/iis I'm able to access {container's IP}:80.

Given the above, what am I doing wrong that is causing my web app container to be inaccessible to the Windows VM host? I'm able to ping 172.20.76.30 with results, and my container is able to ping 172.20.64.1 (its Gateway IP which corresponds with the Windows VM host) but that's as far as I've been able to get in confirming the path between the two network hosts.

Finally, I'll conclude with the observation that the app runs perfectly fine on the Windows VM. I'm able to issue the exact same command dotnet WebApi.dll directly and access the site using localhost:5000 in Chrome.


Solution

  • Figured out the solution. I swapped the base image for the Dockerfile from FROM microsoft/dotnet:1.1-runtime-nanoserver to FROM microsoft/aspnetcore:1.1.2-nanoserver and suddenly everything worked.

    I'm a bit surprised this works since I can run dotnet WebApi.dll from my local machine without a problem, but I'm just glad I found an image/tag that works!