Creating Docker images for your ASP.NET Core application
You can create, dockerize, or containerize your application using different tools. In this section, you will learn how to containerize your application with a Dockerfile, Docker CLI, VS Code, and Visual Studio.
Containerizing an ASP.NET Core application with the Docker CLI and Dockerfile
Follow these steps to get started:
- First, you need to create an empty .NET Core 6.0 web app. Here is the command to create an empty web app; you can create any type of ASP.NET Core application – MVC, Web API, or Razor Pages:
> dotnet new web -o Chapter02 --framework net6.0
The -o
parameter creates the project in the Chapter02
folder and the framework version is .NET 6.0 – this is required if you don’t have multiple versions installed on your machine.
- Next, in the project root folder, create a file with the name
Dockerfile
– no file extension. Then, paste the following code into the Dockerfile...