docker - 我正在使用 Azure Devops 构建和推送我的 Docker 映像。如何在使用 Docker 任务进行 buildAndPush 时传递参数?
问题描述
我创建了一个管道来构建 Docker 映像并将其推送到我的容器注册表。我正在使用 Docker 任务来执行此操作(buildAndPush 命令)。这是“构建和推送”步骤的 YAML 片段:
- task: Docker@2
displayName: Build and Push
inputs:
command: buildAndPush
containerRegistry: dockerRegistryServiceConnection1
repository: contosoRepository
tags: latest
arguments: --label buildtype=nightly
输入arguments
被任务忽略。如何将参数传递给 Docker 命令?
解决方案
buildAndPush
在 Docker 任务中使用命令时,将arguments
被忽略。由于这是两个 Docker 命令的组合,因此arguments
输入变得不明确。
如果你想为你的构建命令添加一些参数,你可以将构建和推送分成两个单独的步骤,如下所示:
- task: Docker@2
displayName: Build
inputs:
command: build
containerRegistry: dockerRegistryServiceConnection1
repository: contosoRepository
tags: latest
arguments: --label buildtype=nightly
- task: Docker@2
displayName: Push
inputs:
command: push
containerRegistry: dockerRegistryServiceConnection1
repository: contosoRepository
tags: latest
推荐阅读
- android - Raw body request with retrofit
- python - 大熊猫在奇数行取平均值
- jquery - 如何更改select2下拉列表的颜色
- dart - iOS 设备中的 Flutter 布局问题,iOS 设备中的混乱布局
- javascript - 如果单击,则添加活动类
- javascript - Expressjs 保存功能不保存用户更改
- java - Java 中的 HashMap 中缺少 put 和 get 函数
- angularjs - 如何将变量绑定到AngularJS中的对象?
- php - PHP 将 ISO-8859-3 字符转换为 UTF-8
- c++ - 如何将结构/联合数组的成员传递给函数