Tag a Docker container as latest in Azure DevOps

Enrico Rossini 201 Reputation points
2022-03-03T08:18:26.51+00:00

I'm trying to build a Docker container and push it to Azure Container Registry. For that, I created this azure-pipeline.yml

# Docker  
# Build and push an image to Azure Container Registry  
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker  
 
trigger:  
- main  
 
resources:  
- repo: self  
 
variables:  
  # Container registry service connection established during pipeline creation  
  dockerRegistryServiceConnection: '...'  
  imageRepository: 'mycontainer'  
  containerRegistry: 'azuk.azurecr.io'  
  dockerfilePath: '$(Build.SourcesDirectory)/dockerfile'  
  tag: '$(Build.BuildId)'  
 
  # Agent VM image name  
  vmImageName: 'ubuntu-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)  

The pipeline is working. Now, I have another Azure pipeline that build another container but the base is the first container. For this reason, in the Dockerfile in the first line I added

FROM azuk.azurecr.io/mycontainer  

When the pipeline starts, I get an error

manifest for ***/mycontainer:latest not found: manifest unknown: manifest tagged by "latest" is not found

I can't find a way to tell the ACR that the last push is the latest version. I saw few posts where they use the property includeLatestTag that doesn't exist anymore

- stage: Build  
  displayName: Build image  
  jobs:    
  - job: DockerImage  
    displayName: Build and push Docker image  
    steps:  
    - task: Docker@1  
      displayName: 'Build the Docker image'  
      inputs:  
        containerregistrytype: 'Container Registry'  
        dockerRegistryEndpoint: 'Docker Hub'  
        command: 'Build an image'  
        dockerFile: '**/Dockerfile'  
        imageName: '$(ImageName)'  
        includeLatestTag: true  
        useDefaultContext: false  
        buildContext: '.'  

How can I add the tag latest to the Docker container and push it to the Azure Container Registry via a Azure DevOps pipeline?

Community Center Not monitored
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,487 Reputation points Moderator
    2022-03-03T09:00:34.943+00:00

    @Enrico Rossini

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    Azure DevOps is currently not supported on Microsoft Q&A. Please check this supported products list here (more to be added later on).

    You can ask your query in the dedicated developer community here, Azure DevOps team and community are active and answering the queries.

    You can also ask for help here on Stack Overflow: https://stackoverflow.com/questions/tagged/azure-devops.

    Please post your question on the forums shared above and the experts will guide you.

    Hope that helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.