Azure Pipeline推送Docker镜像失败:本地无对应标签镜像
问题原因及解决方案
你的镜像构建后无标签、推送失败的核心原因是Docker@2构建任务缺少repository参数:
当前的Build步骤只指定了tags: tag1,但没有关联仓库名称,导致Docker无法将镜像标记为[仓库名]:tag1的完整格式,最终生成的是无归属的<none>:<none>镜像,推送步骤自然找不到对应标签的镜像。
修正后的Pipeline配置
修改Build任务,添加与Push步骤一致的repository参数:
trigger: - master resources: - repo: self steps: - task: Docker@2 displayName: Login to ACR inputs: command: login containerRegistry: myDockerHubConnection - task: Docker@2 displayName: Build an image inputs: command: build arguments: --build-arg git_personal_token=ghp_MYTOKEN dockerfile: '$(Build.SourcesDirectory)/Dockerfile' repository: 'crooksey201/ngx-int-api' # 和Push步骤的仓库名保持一致 tags: tag1 - task: Docker@2 displayName: Push image inputs: repository: 'crooksey201/ngx-int-api' #dockerhubAccountName/repoName command: push tags: tag1
说明
添加repository参数后,Build步骤会将镜像标记为crooksey201/ngx-int-api:tag1,和Push步骤要推送的镜像标签完全匹配,就能成功找到本地镜像完成推送。
内容的提问来源于stack exchange,提问作者crooksey
相关产品推荐
相关产品推荐

