1
votes

I am having a docker application. The build and image build gets successful when I build the image from local machine. But when I moved my code to azure devops, its failing. First I have just moved the code and build the code with Hosted VS2017 agent provided by Azure DevOps. The build was successfully. I have used custom build agent also, and the build was successful. Later I have added docker task to build pipeline to build the image. The image build getting failed with below error.

[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://[email protected]/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

I have enter below options in that build docker step.

containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: mydockerconnection
dockerFile: WebApplication1/Dockerfile
arguments: 'source=obj\docker\publish'
imageName: 'myfirstproject:$(Build.BuildId)'
includeLatestTag: true
useDefaultContext: false
buildContext: WebApplication1
1
can you show how you defined the docker build step?4c74356b41
I have added docker step in build pipeline and given below options in that step. containerregistrytype: 'Container Registry' dockerRegistryEndpoint: mydockerconnection dockerFile: WebApplication1/Dockerfile arguments: 'source=obj\docker\publish' imageName: 'myfirstproject:$(Build.BuildId)' includeLatestTag: true useDefaultContext: false buildContext: WebApplication1. Is there anything I am missing?Raja Kondla
Sorry. I have done it as you said. Thank you.Raja Kondla
I dont see a source argument in the docker build arguments. docs.docker.com/v17.09/engine/reference/commandline/build. also, arguments are supposed to be prepended with --4c74356b41
You are correct. After adding --build-args, the image build succeeded. Never guessed of it.You saved me. Thanks a lot.Raja Kondla

1 Answers

0
votes

in this case the problem was due to forgetting to supply the --build-arg argument