-
March 29th, 2022, 11:46 PM
#1
How to create new .NET Core application and then build and run it using Docker
Dependencies for an application
• Windows 10 is required for Docker installation.
• Visual Studio 2017 or higher has built-in support for Docker, so this is highly recommended.
• .NET Core SDK
• Docker for Windows
• Docker Tools
Why should we use microservices instead of a monolithic approach?
Microservices is an approach to develop small services that each run in its own process. We should develop microservices instead of one service (a monolithic approach) for a multitude of benefits, including:
Microservices are smaller in size
Microservices are easier to develop, deploy, and debug, because a fix only needs to be deployed onto the microservice with the bug, instead of across the board
Microservices can be scaled quickly and can be reused among different projects
Microservices work well with containers like Docker
Microservices are independent of each other, meaning that if one of the microservices goes down, there is little risk of the full application shutting down.
Why should we use .NET Core?
.NET Core is a great development tool for many reasons, including that it’s open source and is very helpful in developing high-performance and scalable systems. It supports cross-platform runtime, so if one can create a service using .NET Core, it can be run on any platform. .NET Core is also helpful for faster development, as well as supporting built-in dependency injection and a cloud-based environment configuration. .NET Core also has Docker support.
Why should we use Docker?
Docker is a tool that makes it easier to create, deploy, and run applications by using a containerization approach. These containers are lightweight and take less time to start than traditional servers. These containers also increase performance and lower cost, while offering proper resource management. Another benefit to using Docker is that a user no longer need to pre-allocate RAM to each container.
How to create a new application using .NET Core and then build and run it using Docker
Step 1: Open Visual Studio 2019, then create a new project
Step 2: Select ASP.Net Core Web App, then click on Next
Step 3: Provide the Project Name and Location to save the project
Step 4: Select Target Framework as ".Net Core 3.1" or higher. Also Enable Docker Checkbox then click on "Create"
Step 5(optional): Once the project is created it will prompt to Install Docker, if the Docker is not installed on the machine yet
Step 6: Solution will be created with a Dockerfile in the file list
Step 7: Build the solution, application will open in the browser
Step 8: To check the docker images, cmd to the project folder and type the command "docker images"
Here are some of the commands for the docker images
To restore packages: dotnet restore
To publish the application code: dotnet publish -o obj/Docker/publish
To build the image: docker build -t imagename
Check running containers: docker ps
Check all containers: docker ps -a
-
March 30th, 2022, 04:39 AM
#2
Re: How to create new .NET Core application and then build and run it using Docker
Well, this is
Forum: C-Sharp Programming
Post questions, answers, and comments about C#.
So is you post a question, an answer, or a comment?
Victor Nijegorodov
-
March 31st, 2022, 10:46 PM
#3
Re: How to create new .NET Core application and then build and run it using Docker
I have posted steps to create new .NET Core application
-
April 1st, 2022, 03:20 AM
#4
Re: How to create new .NET Core application and then build and run it using Docker
Victor Nijegorodov
-
April 6th, 2022, 05:47 PM
#5
Re: How to create new .NET Core application and then build and run it using Docker
I have posted two articles on codeguru, it shows up in threads but not as an article.
Wondering how to get this posted under the article section?
-
April 7th, 2022, 03:43 AM
#6
Re: How to create new .NET Core application and then build and run it using Docker
Originally Posted by srilatha0515
I have posted two articles on codeguru, it shows up in threads but not as an article.
Wondering how to get this posted under the article section?
But why don't you want to post it in a FAQ section?
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|