Containerizing your own .NET projects
So far in this chapter, we have learned about containerization concepts and the Docker tools. Now, let’s see how to use these new tools and skills with .NET development.
In this section, we will look at two types of .NET projects: a console app and an ASP.NET Core website.
Containerizing a console app project
Let’s go:
- Use your preferred code editor to add a new Class Library /
classlib
project namedEnvironmentLib
to aChapter15
solution. - Rename
Class1.cs
toEnvironmentInfo.cs
. - In
EnvironmentInfo.cs
, replace the existing statements with statements to store information about the current environment, as shown in the following code:using System.Net; // To use Dns. using System.Runtime.InteropServices; // To use RuntimeInformation. namespace EnvironmentLib; public class EnvironmentInfo { public string UserName { get; } = Environment.UserName; public string HostName { get; } = Dns.GetHostName...