Cloud Native 12 min read

Running ASP.NET Core in Docker on Linux and Windows Containers (including Nano Server and Server Core)

This article explains how to develop, containerize, and run ASP.NET Core applications using Docker on both Linux and Windows containers, covering setup, Dockerfile creation, publishing, and deployment on Windows Nano Server and Server Core with practical code examples.

DevOps
DevOps
DevOps
Running ASP.NET Core in Docker on Linux and Windows Containers (including Nano Server and Server Core)

The author introduces Linux and Windows containers, noting that Windows supports both kernel‑level and Hyper‑V‑level containers and integrates with Docker, enabling ASP.NET Core apps to run in Docker on either platform.

Required tools are listed: Visual Studio Community 2015 (Update 3), ASP.NET Core with .NET Core 1.0.1, Docker for Windows (Beta), and Visual Studio Tools for Docker.

Docker for Windows automates Hyper‑V setup, creating a Linux‑based Docker host VM, allowing the developer to work from Visual Studio or the command line.

Creating a new ASP.NET Core project in Visual Studio and adding Docker support generates a basic Dockerfile and docker‑compose files.

FROM microsoft/aspnetcore:1.0.1
ENTRYPOINT ["dotnet", "WebApplication4.dll"]
ARG source=.
WORKDIR /app
EXPOSE 80
COPY $source .

The author publishes the app, builds the image, and runs it with Docker commands, showing the resulting container ID and confirming the app runs inside a Linux container on Windows.

>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

Next, the article demonstrates running ASP.NET Core in a Windows Nano Server container. A new Dockerfile targets the Nano Server base image, sets the ASP.NET Core URL, and exposes port 82.

FROM microsoft/dotnet:nanoserver
ENTRYPOINT ["dotnet", "WebApplication4.dll"]
ARG source=.
WORKDIR /app
ENV ASPNETCORE_URLS http://+:82
EXPOSE 82
COPY $source .

After publishing and building the image, the container is run with port mapping. A known NAT bug prevents accessing the app via http://localhost:82 ; instead the container’s IP must be used, obtained with docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" HASH .

>docker run -it -d -p 88:82 aspnetcoreonnano
afafdbead8b04205841a81d974545f033dcc9ba7f761ff7e6cc0ec8f3ecce215

>docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" afa
172.16.240.197

The article notes that Windows containers are fast and lightweight, and they can be isolated using Hyper‑V with the --isolation=hyperv flag.

docker run --isolation=hyperv -it -d -p 86:82 aspnetcoreonnano

Finally, the author switches to a full Windows Server Core image, which is larger (~8 GB) but provides a complete Windows environment. The Dockerfile is updated accordingly.

FROM microsoft/dotnet:1.0.0-preview2-windowsservercore-sdk
ENTRYPOINT ["dotnet", "WebApplication4.dll"]
ARG source=.
WORKDIR /app
ENV ASPNETCORE_URLS http://+:82
EXPOSE 82
COPY $source .

Images for both Nano Server and Server Core are listed, and the author shows running multiple containers (ASP.NET Core, Redis, SQL) to form a full web cluster.

In summary, the article provides step‑by‑step guidance, Dockerfiles, and command‑line examples for deploying ASP.NET Core applications in Linux containers, Windows Nano Server containers, and Windows Server Core containers, highlighting tooling, performance, and troubleshooting tips.

DockerdevopsASP.NET CoreLinux ContainersWindows containersNano ServerServer Core
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.