0

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
0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

How do you manage access into ACR from the pipeline? All I'm getting is "##[error]denied: requested access to the resource is denied".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.