'I am using Azure Devops to build and push my Docker image. How can I pass arguments while doing buildAndPush using Docker task?
I have created a pipeline to build a Docker image and push it to my container registry. I am using Docker task for doing this (buildAndPush command). Here is a YAML snippet of the 'Build and Push' step:
- task: Docker@2
displayName: Build and Push
inputs:
command: buildAndPush
containerRegistry: dockerRegistryServiceConnection1
repository: contosoRepository
tags: latest
arguments: --label buildtype=nightly
The arguments
input is ignored by the task. How can I pass arguments to the Docker command?
Solution 1:[1]
When using buildAndPush
command in Docker task, the arguments
are ignored. Since this is a combination of two Docker commands, the arguments
input becomes ambiguous.
If you want to add some arguments to your build command, you can split build and push into two separate steps like this:
- 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ajinkya |