Running ASP.NET Core 1.0 in Docker

Posted by Anuraj on Tuesday, June 28, 2016

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

WORKDIR /app

RUN ["dotnet", "restore"]

RUN ["dotnet", "build"]

EXPOSE 5000/tcp

ENTRYPOINT ["dotnet", "run", "--server.urls", "http://0.0.0.0:5000"]

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 - 10.0.75.2 (default). Here is the ASP.NET Core application running on Docker.

ASP.NET Core application running on Docker for Windows

Happy Programming :)


Similar Posts


Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



MVP
Subscribe
Archives


Copyright © 2017 - Anuraj P. 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. Hosted with ❤ by GitHub