Sunday, 26 March 2017

Creating DotNet Console application container with Docker

Introduction
In this article I am going to provide step by step tutorial how to create docker image for sample dotnet core console sample application.

Prerequisites
        Below framework needs to be installed on the dev machine
         Dotnet core & docker
   
Steps
   1. Create sample console application  in c# core as below

 
using System;
namespace ConsoleApp1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Test Program");
        }
    }
}
round-color: black; color: white; padding: 20pxdsfjfaskdjf

2. Compile and publish the application in a folder named PublishOutput.

3. Run Command Prompt Windows from PublishOutput directory/folder (cmd should point to PublishOutput folder) and type notepad Dockerfile.

4. Save the file.
5. Make the below entry in the file and save again
FROM microsoft/dotnet:onbuild
ENTRYPOINT ["dotnet", "ConsoleApp1.dll"]
6. Execute >docker build -t testapp .
7. >docker run testapp