Running ASP.NET Core 1.0 in Docker

This post is about running your ASP.NET Core application on Docker for Windows. Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. Recently Docker introduced Docker for Windows and ASP.NET Team came up with Docker support for ASP.NET Core as well. To deploy ASP.NET Core application, first you need to download the docker for Windows. You can get it from here.

Docker for Windows installation is straight forward. Once installation is completed successfully, you will see docker running inside your system tray. And Docker will display a welcome windows like this.

Docker running on Windows

You can verify your docker installation by running “docker run hello-world” command. You will see a response like this.

Docker - Hello World

Once you see this create an application using aspnet yo generator. It will generate a docker file with dotnet core image. Here is the dockerfile.

FROM microsoft/dotnet:latest

COPY . /app


RUN ["dotnet", "restore"]

RUN ["dotnet", "build"]

EXPOSE 5000/tcp

ENTRYPOINT ["dotnet", "run", "--server.urls", ""]

Now you need to create an image with the dockerfile. You can do this using following command.

docker build -t dotnetthoughts/first .

It will create a docker image with the name “dotnetthoughts/first”. You can find the existing images using “docker images” command. Once the docker image created, you can run the docker image using docker run command.

docker run -t -d -p 80:5000 dotnetthoughts/first

Once docker image running, you can see using “docker ps” command. And you can browse the application using the IP Address - (default). Here is the ASP.NET Core application running on Docker.

ASP.NET Core application running on Docker for Windows

Happy Programming :)