Azure Devops Docker Push:本地不存在带有该标签的映像

Sve*_*übe 7 docker spring-boot azure-devops azure-container-registry

我正在使用 spring boot maven 插件在 Azure DevOps 上构建一个 java spring boot 应用程序 docker 容器。之后我想将其推送到天蓝色的容器注册表。但它失败了

本地不存在带有以下标签的镜像:***/my/container

不幸的是,容器 uri 的开头被***. 但正如您在下面的输出中看到的/usr/bin/docker images,容器已注册。我尝试遵循以下示例:https://medium.com/@TimvanBaarsen/build-your-spring-boot-project-using-azure-pipelines-in-azure-devops-3305977991d

管道步骤

steps:
- task: Maven@3
  displayName: "Build Docker image"
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'spring-boot:build-image'
    publishJUnitResults: false
    jdkVersionOption: '1.11'
    mavenOptions: '-Xmx3072m -Dspring-boot.build-image.imageName=acr-foobar.azurecr.io/my/container'

- task: Docker@2
  displayName: Push Docker image
  inputs:
    containerRegistry: 'acr-foobar.azurecr.io'
    repository: 'my/container'
    command: 'push'
    tags: 'latest'
Run Code Online (Sandbox Code Playgroud)

输出 Maven 任务

[INFO] Successfully built image 'acr-***/my/container:latest'
Run Code Online (Sandbox Code Playgroud)

输出 Docker 任务

Starting: Push Docker image
==============================================================================
Task         : Docker
Description  : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
Version      : 2.176.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-docker-tsg
==============================================================================
/usr/bin/docker images
/usr/bin/docker push ***/my/container:latest
REPOSITORY                                             TAG                     IMAGE ID            CREATED             SIZE
paketobuildpacks/run                                   base-cnb                523e5e0ad089        6 days ago          87.2MB
node                                                   10                      2457d5f85d32        13 days ago         911MB
node                                                   10-alpine               b328632eb00c        13 days ago         83.6MB
node                                                   12                      1f560ce4ce7e        4 weeks ago         918MB
buildpack-deps                                         stretch                 b39de549c36a        4 weeks ago         835MB
buildpack-deps                                         buster                  f3f98451c17d        4 weeks ago         804MB
debian                                                 9                       c4ccba324c9c        4 weeks ago         101MB
debian                                                 8                       091099bf65ad        4 weeks ago         129MB
node                                                   12-alpine               d8b74300d554        4 weeks ago         89.6MB
ubuntu                                                 14.04                   df043b4f0cf1        7 weeks ago         197MB
jekyll/builder                                         latest                  a8007cad4069        2 months ago        677MB
alpine                                                 3.9                     78a2ce922f86        6 months ago        5.55MB
alpine                                                 3.10                    be4e4bea2c2e        6 months ago        5.58MB
alpine                                                 3.8                     c8bccc0af957        9 months ago        4.41MB
alpine                                                 3.7                     6d1ef012b567        20 months ago       4.21MB
mcr.microsoft.com/azure-pipelines/node8-typescript     latest                  9a948d360778        2 years ago         595MB
gcr.io/paketo-buildpacks/builder                       base-platform-api-0.3   6248029341bb        40 years ago        568MB
acr-***/my/container   latest                  61477479d5e0        40 years ago        283MB
The push refers to repository [***/my/container]
An image does not exist locally with the tag: ***/my/container
##[error]An image does not exist locally with the tag: ***/my/container
##[error]The process '/usr/bin/docker' failed with exit code 1
Finishing: Push Docker image
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?

Ash*_*hok 14

就我而言

containerRegistry我注意到,如果设置了值或存在服务连接,则在构建和发布任务中指定注册表名称。我的发布步骤指定了此属性,但我的构建步骤没有指定。

我更改了构建步骤以传递此参数,并在这两个步骤中创建了正确的标签来解决问题。

可以试试这个希望对你有帮助。


Rob*_*iel 5

看起来容器构建的容器镜像标签是,acr-***/my/container而您尝试推送的镜像标签是,所以出于某种原因,它从标签名称中***/my/container删除了。acr-

这可能是因为 Azure 容器注册表的名称存在问题。它的名称中不应包含连字符。

在此输入图像描述

您确定您的容器注册表名为 吗acr-foobar.azurecr.io