如何在VS2019中自定义Docker映像名称

问题描述 投票:0回答:2

在vs2019中,我在输出窗口中生成了docker镜像,生成镜像的原始命令是:

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"

我想将图像名称rookieqwtwebapi更改为registry.rookie.qwt.webapi,如何在vs2019中使用它?

asp.net-mvc docker asp.net-core .net-core visual-studio-2019
2个回答
0
投票

使用--tag-t速记为泊坞窗映像添加自定义名称。您还可以添加带有图像名称的标签。此处更多信息-https://docs.docker.com/engine/reference/commandline/build/

运行此命令以查看图像名称:

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

0
投票

我想将图像名称rookieqwtwebapi更改为registry.rookie.qwt.webapi,如何在vs2019中进行呢?

根据Microsoft's docs,为此目的有一个参数DockerfileTag

构建Docker映像时将使用的标签。在调试中,将“:dev”附加到标签。

如下操作:

  1. 在解决方案资源管理器中双击您的项目名称
  2. 编辑项目文件,添加自定义<DockerfileTag/>
 netcoreapp3.1  TargetFramework> 65be249c-09e1-45ea-bac9-45d1cb4c82b6  UserSecretsId> Linux  DockerDefaultTargetOS> PropertyGroup>
© www.soinside.com 2019 - 2024. All rights reserved.