In May of last year doing things with ASP.NET and Docker was in its infancy. But cool stuff was afoot. I wrote a blog post showing how to publish an ASP.NET 5 (5 at the time, now Core 1.0) app to Docker. Later inDecember of 2015 new tools like Docker Toolbox and Kitematic made things even easier. In May of 2016 Docker for windows Beta continued to move the ball forward nicely.
I wanted to see how things are looking with ASP.NET Core, Docker, and Windows here in October of 2016.
I installed these things:
Visual Studio Community 2015 Visual Studio 2015 Update 3 ASP.NET Core with .NET Core .NET Core 1.0.1 - VS 2015 Tooling Preview 2 Docker for Windows (I used the Beta Channel) Visual Studio Tools for DockerDocker for Windows is really nice as it automates setting up Hyper-V for you and creates the Docker host OS and gets it all running. This is a big time saver.

There's my linux host that I don't really have to think about. I'll do everything from the command line or from Visual Studio.
I'll say File | New Project and make a new ASP.NET Core application running on .NET Core.
Then I right click and Add | Docker Support . This menu comes from the Visual Studio Tools for Docker extension. This adds a basic Dockerfile and some docker-compose files. Out of the box, I'm all setup to deploy my ASP.NET Core app to a Docker Linux container.
ASP.NET Core in a Docker Linux ContainerStarting from my ASP.NET Core app, I'll make sure my base image (that's the FROM in the Dockerfile) is the base ASP.NET Core image for Linux.
FROM microsoft/aspnetcore:1.0.1ENTRYPOINT ["dotnet", "WebApplication4.dll"]
ARG source=.
WORKDIR /app
EXPOSE 80
COPY $source .
Next, since I don't want Docker to do the building of my application yet, I'll publish it locally. Be sure to read Steve Lasker's blog post " Building Optimized Docker Images with ASP.NET Core " to learn how to have one docker container build your app and the other run it it. This optimizes server density and resource.
I'll publish, then build the images, and run it.
>dotnet publish>docker build bin\Debug\netcoreapp1.0\publish -t aspnetcoreonlinux
>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
aspnetcoreonlinux latest dab2bff7e4a6 28 seconds ago 276.2 MB
microsoft/aspnetcore 1.0.1 2e781d03cb22 44 hours ago 266.7 MB
>docker run -it -d -p 85:80 aspnetcoreonlinux
1cfcc8e8e7d4e6257995f8b64505ce25ae80e05fe1962d4312b2e2fe33420413
>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cfcc8e8e7d4 aspnetcoreonlinux "dotnet WebApplicatio" 2 seconds ago Up 1 seconds 0.0.0.0:85->80/tcp clever_archimedes
And there's my ASP.NET Core app running in Docker. So I'm running Windows, running Hyper-V, running a Linux host that is hosting Docker containers.
What else can I do?
ASP.NET Core in a Docker Windows Container running Windows Nano ServerThere's Windows Server , there's Windows Server Core that removes the UI among other things and there's Windows Nano Server which gets Windows down to like hundreds of megs instead of many gigs. This means there's a lot of great choices depending on what you need for functionality and server density. Ship as little as possible.
Let me see if I can get ASP.NET Core running on Kestrel under Windows Nano Server. Certainly, since Nano is very capable, I could run IIS within the container and there's docs on that .
Michael Friis from Docker has a great blog post on building and running your first Docker Windows Server Container . With the new Docker for Windows you can just right click on it and switch between Linux and Windows Containers.

So now I'm using Docker with Windows Containers. You may not know that you likely already have Windows Containers! It was shipped inside Windows 10 Anniversary Edition. You can check for Containers in Features:

I'll change my Dockerfile to use the Windows Nano Server image. I can also control the ports that ASP.NET talks on if I like with an Environment Variable and Expose that within Docker.
FROM microsoft/dotnet:nanoserverENTRYPOINT ["dotnet", "WebApplication4.dll"]
ARG source=.
WORKDIR /app
ENV ASPNETCORE_URLS http://+:82
EXPOSE 82
COPY $source .
Then I'll publish and build...
>dotnet publish>docker build bin\Debug\netcoreapp1.0\publish -t aspnetcoreonnano
Then I'll run it, mapping the ports from Windows outside to the Windows container inside!
NOTE:There's a bug as of this writing that affects how Windows 10 talks to Containers via "NAT" (Network Address Translation) such that you can't easily go http://localhost:82 like you (and I) want to. Today you have to hit the IP of the container directly. I'll report back once I hear more about this bug and how it gets fixed. It'll show up in Windows Update one day. The workaround is to get the IP address of the container from docker like this: docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" HASH
So I'll run my ASP.NET Core app on Windows Nano Server (again, to be clear, this is running on Windows 10 and Nano Server is inside a Container!)
>docker run -it -d -p 88:82 aspnetcoreonnanoafafdbead8b04205841a81d974545f033dcc9ba7f761ff7e6cc0ec8f3ecce215
>docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" afa
172.16.240.197
Now I can hit that site with 172.16.240.197:82. Once that bug above is fixed, it'll get hit and routed like any container.
The best part about Windows Containers is that they are fast and lightweight. Once the image is downloaded and build on your machine, you're starting and stopping them in seconds with Docker.
BUT, you can also isolate Windows Containers using Docker like this:
docker run --isol