crooksey
crooksey

Reputation: 8809

Problem pushing docker image from azure pipeline

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?

Upvotes: 2

Views: 1231

Answers (2)

crooksey
crooksey

Reputation: 8809

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)

Upvotes: 3

Xiang ZHU
Xiang ZHU

Reputation: 436

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

Upvotes: 0

Related Questions