【问题标题】:build failed when I added docker task to azure build pipeline当我将 docker 任务添加到天蓝色构建管道时构建失败
【发布时间】:2019-04-18 05:49:18
【问题描述】:

我有一个 docker 应用程序。当我从本地计算机构建映像时,构建和映像构建成功。但是当我将我的代码移动到 azure devops 时,它失败了。首先,我刚刚移动了代码并使用 Azure DevOps 提供的托管 VS2017 代理构建了代码。构建成功。我也使用了自定义构建代理,构建成功。后来我添加了 docker 任务来构建管道来构建图像。图像构建失败并出现以下错误。

[command]"C:\Program Files\Docker\docker.exe" build -f D:\a\1\s\WebApplication1\Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/rajakondla/ --label com.azure.dev.image.system.teamproject=MyProject --label com.azure.dev.image.build.repository.name=MyProject --label com.azure.dev.image.build.repository.uri=https://rajakondla@dev.azure.com/rajakondla/MyProject/_git/MyProject --label com.azure.dev.image.build.sourcebranchname=master --label com.azure.dev.image.build.sourceversion=51666d2f6f03878358e22acd7c68787eeba7b2e9 --label com.azure.dev.image.build.definitionname=MyFirstBuild --label com.azure.dev.image.build.buildnumber=20190418.1 --label com.azure.dev.image.build.builduri=vstfs:///Build/Build/24 --label "com.azure.dev.image.build.requestedfor=Raja Kondla" source=obj\docker\publish -t myfirstproject:24 D:\a\1\s\WebApplication1

"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile
[error]C:\Program Files\Docker\docker.exe failed with return code: 1

我在构建 docker 步骤中输入了以下选项。

containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: mydockerconnection
dockerFile: WebApplication1/Dockerfile
arguments: 'source=obj\docker\publish'
imageName: 'myfirstproject:$(Build.BuildId)'
includeLatestTag: true
useDefaultContext: false
buildContext: WebApplication1

【问题讨论】:

  • 您能说明您是如何定义docker build 步骤的吗?
  • 我在构建管道中添加了 docker 步骤,并在该步骤中给出了以下选项。 containerregistrytype: 'Container Registry' dockerRegistryEndpoint: mydockerconnection dockerFile: WebApplication1/Dockerfile 参数: 'source=obj\docker\publish' imageName: 'myfirstproject:$(Build.BuildId)' includeLatestTag: true useDefaultContext: false buildContext: WebApplication1。有什么我想念的吗?
  • 对不起。我已经按照你说的做了。谢谢。
  • 我在docker build 参数中没有看到source 参数。 docs.docker.com/v17.09/engine/reference/commandline/build。此外,参数应该以-- 开头
  • 你是对的。添加 --build-args 后,镜像构建成功。万万没想到,你救了我。非常感谢。

标签: docker azure-devops


【解决方案1】:

在这种情况下,问题是由于忘记提供 --build-arg 参数

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-18
    • 1970-01-01
    • 2022-12-17
    • 1970-01-01
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 2021-08-09
    相关资源
    最近更新 更多