skip to Main Content

I have pushed a new image in the azure container registry

enter image description here

But i am unable to find the image in azure container registry
enter image description here

Please find the deplyment yaml file

name: Dotnet Code Build and Push
jobs:
- job: Job_1
  displayName: Agent job 1
  pool:
    vmImage: ubuntu-18.04
  steps:
  - checkout: self
  - task: Docker@0
    displayName: Build an image
    inputs:
      azureSubscription: 'sc-***dp'
      azureContainerRegistry:
      loginServer: *****aksacr.azurecr.io
      id: "/subscriptions/4f76bb2f-c521-45d1-b311-b87bf**747ff/resourceGroups/eus-***dp-rg/providers/Microsoft.ContainerRegistry/registries/*****aksacr"
      imageName: ***dpacr.azurecr.io/ims-***dp/$(Build.Repository.Name):$(Build.BuildId)
  - task: Docker@2
    displayName: Login to ACR
    inputs:
      command: login
      containerRegistry:'sc-***dp'
  - task: Docker@2
    displayName: Push an image
    inputs:
      azureSubscription: 'sc-***dp'
      repository: ims-***dp
      azureContainerRegistry: '{"loginServer":"*****aksacr.azurecr.io", "id" : "/subscriptions/4f76bb2f-c521-45d1-b311-b87bf**747ff/resourceGroups/eus-***dp-rg/providers/Microsoft.ContainerRegistry/registries/*****aksacr"}'
      action: Push an image

3

Answers


  1. I would recommend to create a new service connection with the container registry if one does not exist.

    enter image description here

    and select Azure Container Registry.

    enter image description here

    Then you can push in your registry using the below task. Keep in mind that ${{container}} should have a notation as xxx.azurecr.io/imagename:tag

     - task: Docker@2
        displayName: pushing image ${{container}} 
        inputs:
          containerRegistry: 'serviceConnectionName'
          repository: '${{container}}'
          command: 'push'
          tags: |
            mytag 
    
    Login or Signup to reply.
  2. Try to push the code in azure devops pipeline so you can directly push image in azure container registry

    Here we can docker task it can build up and push the image with help of setting and it take the image from repository and then it can push into the azure container registry

     task: Docker@2
        displayName: Push an image
        inputs:
          command: buildAndpush
           repository: $(imageRepository)
           dockerfile: $(dockerfilepath)
               ContainerRegistry: $(dockerRepositoryserviceconnectio)
               tags:
                   $(tag)
    

    Save and run.

    enter image description here

    Note : After running you can’t see Repository please refresh again because in azure pipeline the job may be still running once the job is completed & successfully run and refresh you can able see image is pushed

    Please refer this document by rajaniesh kaushikk has given detail information

    Login or Signup to reply.
  3. Please check the repository and containerRegistry value in your Docker@2 task, make sure they points to target resource. My script for your reference below. Please note the parameters in Docker@2 task, no azureContainerRegistry and command needed.

    variables:
      dockerRegistryServiceConnection: acrconn1
      imageRepository: 'acrlearn'
      containerRegistry: 'test.azurecr.io'
      dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
      tag: '$(Build.BuildId)'
    
      # Agent VM image name
      vmImageName: 'windows-latest'
    
    stages:
    - stage: Build
      displayName: Build and push stage
      jobs:
      - job: Build
        displayName: Build
        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)
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search