skip to Main Content

I have an azure devops pipeline.

    trigger:
- master

resources:
- repo: self

steps:
  - task: Docker@2
    displayName: Login to ACR
    inputs:
      command: login
      containerRegistry: myDockerHubConnection

  - task: Docker@2
    displayName: Build an image
    inputs:
        command: build
        arguments: --build-arg git_personal_token=ghp_MYTOKEN
        dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
        tags: tag1

  - task: Docker@2
    displayName: Push image
    inputs:
        repository: 'crooksey201/ngx-int-api' #dockerhubAccountName/repoName
        command: push
        tags: tag1

This builds my image fine, but on the push stage, I get the error:

##[error]An image does not exist locally with the tag: ***/ngx-int-api

And in the list of docker images I just get:

REPOSITORY       TAG         IMAGE ID       CREATED                  SIZE
<none>           <none>      f705e0d37a95   Less than a second ago   1.76GB

This image has no tag which I am confused about, as I think I have specified the tags correctly in my pipeline, can anyone spot my error?

2

Answers


  1. Chosen as BEST ANSWER

    The issue was relating to the quotes around repository I updated a few things, but a working YAML is:

    trigger:
    - master
    
    resources:
    - repo: self
    
    variables:
      tag: '$(Build.BuildId)'
    steps:
      - task: Docker@2
        displayName: Login to ACR
        inputs:
          command: login
          containerRegistry: DockerHubConnectionName
    
      - task: Docker@2
        displayName: Build an image
        inputs:
            containerRegistry: DockerHubConnectionName
            repository: mydockerhubusername/my-repo
            command: build
            arguments: --build-arg git_personal_token=ghp_MYTOKEN
            dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
            tags: |
              $(tag)
      - task: Docker@2
        displayName: push the image
        inputs:
            containerRegistry: DockerHubConnectionName
            repository: mydockerhubusername/my-repo
            command: push
            tags: |
              $(tag)
    

  2. some of the inputs of the task Docker@2 in your example are not documented, and the imageName: might be repository:.

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