未能在 Azure 管道重命名 docker 图像

Fail to rename docker image at Azure pipelines

我尝试使用此任务重命名构建映像:

steps:
- task: Docker@0
  displayName: 'Run a Docker TAG rename'
  inputs:
    containerregistrytype: 'Container Registry'
    dockerRegistryConnection: 'docker hub'
    action: 'Run a Docker command'
    customCommand: 'tag  azuretp:latest (my docker hub account)/dockerhub:myfirstpush'

但因错误而失败:

"C:\Program Files\Docker\docker.exe" tag azuretp:latest ***/dockerhub:myfirstpush
Error response from daemon: No such image: azuretp:latest

运行 在本地我可以重命名它,使用命令:

docker tag trfoutwsrv:dev (my docker hub account)/dockerhub:myfirstpush

在 Azure Pipeline Services 中,图像名称随构建而变化。我已经尝试过 azuretp:{Build.BuildNumber} 但该变量在任务 运行 时不存在。

目标是重命名图像,以便可以将其推送到我的 docker 中心存储库。 本来任务已经拆分重命名然后push了,现在卡在重命名中

在这种情况下,解决方案是使用 azuretp:$(Build.BuilNumber)