Ubuntu Core Docker

The Canonical Ubuntu take on this idea: 'Ubuntu Core is the smallest, leanest Ubuntu ever, perfect for ultra-dense computing in cloud container farms, Docker app deployments or Platform as a. Pingback: ASP.NET Core deployment using Docker, Nginx and Ubuntu Server - How to Code.NET Pingback: Dew Drop - June 12, 2017 (#2498) - Morning Dew Server 2016 Migration Experts 13 June 2017 at 14:31.

Since ASP.NET Core became a truly cross-platform framework, we’re free to use other environments such as Linux in order to host our applications. This is a great opportunity not only to reduce the possible licensing costs but also to try out a new environment. In the video tutorial below, I’ll show you how to build a Docker image using ASP.NET Core, publish it to the Virtual Machine running in the Digital Ocean and use Nginx to expose the app to the world.


1. Creating a sample web application

At the very beginning let’s create a sample ASP.NET Core application using the available template. It does not matter whether you choose the MVC or Web API.

Just type dotnet new mvc, then dotnet restore and eventually dotnet run to make sure that the application works under the default localhost:5000 URL.

2. “Dockerizing” ASP.NET Core application

Core

In order to build the Docker image create a new Dockerfile within the root directory of a project:

Ubuntu Core Docker

2
4
6
8
10
listen80;
location/{
proxy_set_header Upgrade$http_upgrade;
proxy_set_header Host$host;
}

Ubuntu Core Docker Image

Eventually, execute the service nginx restart command and that’s it – your web application running within the Docker container should be accessible from the public port of 80. If you’d like to restrict the ports, you can use the UWF and type in commands like ufw allow 80.