Running ASP.NET Core 1.0 in Docker

June 28, 2016 by Anuraj

C# ASP.NET ASP.NET Core Docker Container

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 :)

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub