【问题标题】:Running Docker container in Azure pipeline running on self hosted agent that is running in the container as well在 Azure 管道中运行 Docker 容器,该管道在容器中运行的自托管代理上运行
【发布时间】:2022-08-15 20:31:28
【问题描述】:

我正在尝试在我的 Azure 管道中提取 Docker 容器。 Azure 管道在自托管代理上运行,该代理在 docker 容器中运行。我收到以下错误:

当管道本身在容器自托管代理上运行时,是否可以在管道中运行容器?

管道 YAML:


# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

resources:
  containers:
  - container: qmate
    image: qmate.int.repositories.cloud.sap/qmate-executor:latest

pool:
  vmImage: ubuntu-latest
  name: SYS-DEV-Self-hosted
  demands:
    - agent.name -equals SYSDEV-agent
    
steps:
- task: NodeTool@0
  inputs:
    versionSpec: \'15.x\'
  displayName: \'Install Node.js\'

- task: DockerInstaller@0
  inputs:
    dockerVersion: \'17.09.0-ce\'

- script:  docker pull qmate
  workingDirectory: ./
  displayName: \'Docker Pull\'

- script: |
    cd tests/QmateE2E/regression
    npm install
    npx wdio config.js
    displayName: \'npm install and build\'

    标签: azure docker azure-pipelines


    【解决方案1】:

    您可以在 docker 容器中 configure the self-hosted agent。 您不需要在管道中运行 docker 容器。您可以在 docker 实例中安装自托管代理。 然后将 docker 容器设置为自托管,可以在代理池中设置。

    【讨论】:

      【解决方案2】:

      您可以specify multiple containers 与容器作业一起运行...(如果您想运行另一个容器与之交互)(您在管道上指定的容器将由 Azure Devops 自动拉取并启动)(我通常会指定要在顶级 container: 或特定作业下运行的容器(如果存在多个作业)。)

      (目前的做法是,如果添加更多容器,安全的选择是有一个target: qmatefor each of the steps that should run in the container

      对于您在此处遇到的错误:对于与 docker 交互的步骤,例如 docker build,您还可以在特定任务上设置 target: host。 (Azure DevOps 似乎挂载了一些东西以允许共享大部分上下文)(在这种情况下,您尝试拉取的图像可能在管道启动时已经拉取)

      【讨论】:

        猜你喜欢
        • 2020-12-14
        • 1970-01-01
        • 2017-12-20
        • 1970-01-01
        • 2022-08-16
        • 2023-03-05
        • 2019-12-05
        • 2021-12-29
        • 1970-01-01
        相关资源
        最近更新 更多