{"id":6680,"date":"2021-02-09T07:23:47","date_gmt":"2021-02-09T07:23:47","guid":{"rendered":"https:\/\/9series-blog.staging9.com\/?p=6680"},"modified":"2026-03-03T10:49:42","modified_gmt":"2026-03-03T10:49:42","slug":"dockerise-automate-build-deployment-process-net-mvc","status":"publish","type":"post","link":"https:\/\/www.9series.com\/blog\/dockerise-automate-build-deployment-process-net-mvc\/","title":{"rendered":"How to Dockerise, Automate the Build and Deployment Process for .NET MVC?"},"content":{"rendered":"<p><a href=\"https:\/\/9series-blog.staging9.com\/wp-content\/uploads\/2021\/02\/How-to-Dockerise-Automate-the-Build-and-Deployment-Process-for-.NET-MVC.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3987 alignleft\" src=\"https:\/\/9series-blog.staging9.com\/wp-content\/uploads\/2021\/02\/How-to-Dockerise-Automate-the-Build-and-Deployment-Process-for-.NET-MVC.jpg\" alt=\"How to Dockerise, Automate the Build and Deployment Process for .NET MVC\" width=\"800\" height=\"500\" \/><\/a><\/p>\n<p>Recently, during an online webinar about Docker with students, some of the students asked us very basic queries and its real-time implementation. So we thought why not write simple blogs in laymen\u2019s terms. And we explained \u201cHow to Dockerize in PHP?\u201d.<\/p>\n<p>For the uninitiated, we are an IT service firm called 9series. We are known as a <a href=\"https:\/\/www.9series.com\/services\/devops-consulting.html\">DevOps service provider company<\/a> that provides different kinds of services varying from IT consultancy services, making an application of iOS, Android, or build a website and containerization. We do all this. We often do webinars to helps those students who want to learn to code.<\/p>\n<p>In this article, We will explain how to dockerize the .NET core application. Before we start the application, The most needed things are:<\/p>\n<ul>\n<li>Windows system<\/li>\n<li>ASP.NET<\/li>\n<li>Docker for Windows (successfully running)<\/li>\n<\/ul>\n<p>We want to dockerize the file so first need to create the docker file. And for that, these are the steps to need to be done\u2026<\/p>\n<p><strong>1.<\/strong> Dockerfile is a text language that can build a docker image with a pack of the required dependencies based on the command written in the Dockerfile.<\/p>\n<p><strong>2.<\/strong> Create a Dockerfile in your project folder.<\/p>\n<p><strong>3.<\/strong> Add the text below to your Dockerfile for either Linux or Windows Containers. The tags below are multi-arch meaning they pull either Windows or Linux containers depending on what mode is set in Docker Desktop for Windows.<\/p>\n<p><strong>4.<\/strong> The Dockerfile assumes that your application is called asp.net app. Change the Dockerfile to use the DLL file of your project.<\/p>\n<p><code style=\"background: #f5f5f5;width: 100%;float: left;padding: 10px\"><br \/>\nFROM mcr.microsoft.com\/dotnet\/core\/sdk:3.1 AS build-env<br \/>\nWORKDIR \/app<br \/>\n# Copy csproj and restore as distinct layers<br \/>\nCOPY *.csproj .\/<br \/>\nRUN dotnet restore<br \/>\n# Copy everything else and build<br \/>\nCOPY . .\/<br \/>\nRUN dotnet publish -c Release -o out<br \/>\n# Build runtime image<br \/>\nFROM mcr.microsoft.com\/dotnet\/core\/aspnet:3.1<br \/>\nWORKDIR \/app<br \/>\nCOPY --from=build-env \/app\/out .<br \/>\nENTRYPOINT [\"dotnet\", \"aspnetapp.dll\"]<br \/>\n<\/code><\/p>\n<p>If I explain those steps then,<\/p>\n<p>First of all, one needs to understand that we need to create a docker image, in order to dockerize the application, and in order to create a docker image we need to create dockerfile. So, create the dockerfile in your folder. Then do write the code given above and then remove the assumption of dockerfile.<\/p>\n<p>To make your build context as small as possible add a .dockerignore file to your project folder and mention which file or folder not required to copy into the image during the build process.<\/p>\n<p>Then we will have to build the Docker Image, and here are steps to do it,<\/p>\n<p><strong>1.<\/strong> Open a command prompt and navigate to your project folder.<\/p>\n<p><strong>2.<\/strong> Use the following commands to build and run your Docker image:<\/p>\n<p><code style=\"background: #f5f5f5;width: 100%;float: left;padding: 10px\"><br \/>\n$ docker build -t aspnetapp.<br \/>\n$ docker run -d -p 8080:80 --name myapp aspnetapp<br \/>\n<\/code><\/p>\n<p>At last, all we need to do is view the page that is running from the container:<\/p>\n<p>Go to localhost:8080 to access your app in a web browser.<\/p>\n<p>So, That\u2019s how you can build and dockerize .NET core applications. In the next article, we will explain the process of building, dockerize, and implementation of Python(Django). We are leading <a href=\"https:\/\/www.9series.com\/services\/docker-consulting.html\">enterprise Docker consulting services<\/a> provider company in USA.<\/p>\n<p>So, stay tuned!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, during an online webinar about Docker with students, some of the students asked us very basic queries and its real-time implementation. So we thought why not write simple blogs&#8230;<\/p>\n","protected":false},"author":1,"featured_media":6681,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"dsgo_overlay_header":false,"dsgo_overlay_header_text_color":"","dsgo_overlay_skip_top_bar":false,"_designsetgo_exclude_llms":false,"footnotes":""},"categories":[1467,1],"tags":[],"class_list":["post-6680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/posts\/6680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/comments?post=6680"}],"version-history":[{"count":1,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/posts\/6680\/revisions"}],"predecessor-version":[{"id":6682,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/posts\/6680\/revisions\/6682"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/media\/6681"}],"wp:attachment":[{"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/media?parent=6680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/categories?post=6680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9series.com\/blog\/wp-json\/wp\/v2\/tags?post=6680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}