How do I enable docker for a .net application with dotnet cli/powershell?

Lelle 0 Reputation points
2023-05-22T11:50:20.3133333+00:00

Hi

How do I enable docker for a .net application with dotnet cli/powershell?

This is how I create my app:

dotnet new sln -n blazortest
dotnet new blazorserver -n blazortest
dotnet sln add blazortest\blazortest.csproj

How do I enable docker/Add docker support (Add dockerfile etc)? I dont want to do it manually.
I know the need for the dockerfile was removed in .net 7, but still.....

Br

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
323 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,080 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Limitless Technology 43,951 Reputation points
    2023-05-23T11:45:26.4066667+00:00

    Hello there,

    For ASP.NET Core projects targeting .NET Core, there are two options for adding Docker support via the tooling. Open the project in Visual Studio, and choose one of the following options:

    Select Docker Support from the Project menu.

    Right-click the project in Solution Explorer and select Add > Docker Support.

    You can use this before article for script guidance https://learn.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=windows

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--


  2. Bruce (SqlWork.com) 56,686 Reputation points
    2023-06-12T17:40:25.33+00:00

    dotnet cli supports additional tools that are hosted in nuget.org

    pick the packages link, click on .net tool and search for docker. maybe this one (I have not used):

    https://github.com/tmds/build-image

    0 comments No comments

  3. Kesava Subhash Gullapudi 30 Reputation points
    2024-03-05T05:47:37.8233333+00:00

    By creating an project enable checkbox of Docker windows or Linux**

    1-Click in Top Menu of VS 2022 button view and find terminal and click upon it

    2-enter the terminal using syntax like docker build -f Name of the appplication/Dockerfile -t sample image name:tag name + . (docker build -f ApplicationName/Dockerfile -t imagename:v1 .)

    3-Run Docker container using (docker container run -d -p 8080:80 imagename:tagname .)

    0 comments No comments