Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the docker image name in VS2019

In vs2019, I generate the docker image in the output window, the original command to generate the image was:

docker build -f "e:\work\dotnetcoreproject\rookie.qwt\rookie.qwt.webapi\dockerfile" --force-rm -t rookieqwtwebapi --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=rookie.Qwt.WebApi" "e:\work\dotnetcoreproject\rookie.qwt"

I want to change the image name rookieqwtwebapi to registry.rookie.qwt.webapi, how can I do it in vs2019?

like image 523
pepperann Avatar asked Jan 13 '20 08:01

pepperann


2 Answers

I want to change the image name rookieqwtwebapi to registry.rookie.qwt.webapi, how can I do it in vs2019?

According to the Microsoft's docs, there's a parameter of DockerfileTag for this purpose:

The tag that will be used when building the Docker image. In debugging, a ":dev" is appended to the tag.

So do it as below:

  1. Double click your project name in Solution Explorer
  2. Edit the project file, add a custom <DockerfileTag/>:
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UserSecretsId>65be249c-09e1-45ea-bac9-45d1cb4c82b6</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <DockerfileTag>registry.rookie.qwt.webapi</DockerfileTag>
  </PropertyGroup>

Now VS will build the image with this tag of registry.rookie.qwt.webapi (or registry.rookie.qwt.webapi:dev when debugging) automatically .

like image 170
itminus Avatar answered Sep 27 '22 19:09

itminus


Go to the Properties of the project and change the Assembly name. It will change the entire image name. Image tag can be added in Publish Profile.

like image 20
cute-marshmallow Avatar answered Sep 27 '22 17:09

cute-marshmallow