0
votes

I am building an Azure DevOps pipeline using a yml file.

In the yml definition I have two stages, one is to build docker images , second stage is to push these images to ACR. I am able to store docker image as build artifact in the first step. I can also download build artifact into $(Pipeline.Workspace). I could not find a way to push image from $(Pipeline.Workspace) to Container registry as docker save does not have parameter to reference $(Pipeline.Workspace) workspace directory.

- task: Docker@2
  displayName: Push Image to Repository
  inputs:
    command: push
1

1 Answers

1
votes

You can try Build and push an image to container registry

- stage: Build
  displayName: Build and push stage
  jobs:  
  - job: Build
    displayName: Build job
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

You can refer to this thread How to build docker image and push to azure container registry