【问题标题】:Azure Devops Docker Push: An image does not exist locally with the tagAzure Devops Docker Push:本地不存在带有标记的映像
【发布时间】:2021-02-22 16:42:30
【问题描述】:

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

本地不存在带有标签的图像:***/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'

输出 Maven 任务

[INFO] Successfully built image 'acr-***/my/container:latest'

输出 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

这里有什么问题?

【问题讨论】:

  • 您是否尝试过使用“docker tag”命令标记图像。
  • @Robin-ManuelThiel 嗯,我也注意到了。但我不知道如何进一步调查它,因为它是 azure devops 的一些屏蔽逻辑:(

标签: spring-boot docker azure-devops azure-container-registry


【解决方案1】:

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

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

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

【讨论】:

  • 有趣。明天我需要和管理注册表的人核实一下。谢谢。 acr-*** 是服务连接的名称。我需要找出注册表 url。
【解决方案2】:

就我而言

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

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

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

【讨论】:

  • 但如您所见:我没有 docker build 任务。我正在使用 spring boot 插件来构建容器。
  • 这与stackoverflow.com/q/63278658/2952093 中的问题相同(以及相同的解决方案)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 2021-10-30
  • 1970-01-01
  • 1970-01-01
  • 2021-01-01
  • 1970-01-01
相关资源
最近更新 更多