【问题标题】:Azure Devops pipeline cannot access a Docker Windows image?Azure Devops 管道无法访问 Docker Windows 映像?
【发布时间】:2021-02-09 11:54:58
【问题描述】:

我正在尝试在 Azure DevOps 上基于 windows:1909 构建 Docker 映像并将其发布到 Azure 注册表。我已经根据 DevOps 提供的模板设置了一个基本管道,将构建器 VM 更改为 windows-latest,但是当我尝试运行它时,我得到以下信息:

Step 1/43 : FROM mcr.microsoft.com/windows:1909
1909: Pulling from windows
no matching manifest for windows/amd64 10.0.17763 in the manifest list entries

我的管道如下:

trigger:
- main

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: '<redacted>'
  imageRepository: '<redacted>'
  containerRegistry: '<redacted>'
  dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
  tag: '$(Build.BuildId)'
  
  # Agent VM image name
  vmImageName: 'windows-latest'

stages:
- stage: Build
  displayName: Build and push stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

我在网上找到的大多数建议是“设置 Docker 以运行 Windows 容器”,但这不是我在 Azure 上可以做的——或者我可以吗?

【问题讨论】:

标签: azure docker azure-devops


【解决方案1】:

以上错误是你基于的Windows Server容器(即windows:1909)与容器主机(即windows-latest agent VM机器)不兼容引起的。

  • window:1909容器的操作系统版本为10.0.18363.1377

  • windows-latest代理虚拟机的os版本为10.0.17763 Build 1697

正如下面this document中所述:

因为 Windows Server 容器和底层主机共享一个内核,所以容器的基础映像操作系统版本必须与主机的版本匹配。如果版本不同,容器可能会启动,但不能保证功能完整。

因此,如果容器主机(即windows-latest 代理 VM 机器)正在运行 Windows Server 2019。部署到此主机的任何 Windows Server 容器都必须基于 Windows Server 版本 2019(10.0.17763) 容器基础映像。

出于上述原因。作为解决方法,您可以在windows-latest 代理上使用window: 1809(操作系统:10.0.17763.1757)或servercore:1809(操作系统:10.0.17763.1757)。请参阅Full Tag Listing

如果你必须构建基于 windows:1909 的 Docker 镜像。您需要在操作系统版本为 10.0.18363 的主机上创建一个self-hosted agent

【讨论】:

  • 这似乎是解决方案。我必须确保windows:1809 足以满足我们的目的,而且看起来确实如此;当我推送该更改时,管道会找到合适的版本。
【解决方案2】:

你可以试试下面的版本

docker pull mcr.microsoft.com/windows/servercore:1809

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-22
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    • 2021-03-25
    • 2022-11-24
    • 2022-08-15
    相关资源
    最近更新 更多