0

I'd like to push my image to Docker Hub. Task seems to be simple, yet I lost with details.

- task: Docker@2
  displayName: Push image
  inputs:
    containerRegistry: |
      $(dockerHub)
    repository: username/repo
    command: push
    tags: latest

What should be the value of $(dockerHub) variable and how to construct it? These instructions seem to explain it, but I don't get it.

Lukasz Dynowski
  • 11,169
  • 9
  • 81
  • 124
  • Not get your latest information. Just want to check whether below answer is helpful for you? If yes, you can accept the answer and we could archive this thread. Also, feel free to leave comment below if still has any puzzle about it:-) – Hugh Lin Mar 04 '21 at 01:48
  • @HughLin-MSFT Thanks for the answer was helpful. I decided to edit it because I spent significant amount of time locating elements in UI. And it was not obvious for me since these are my first days with Azure DevOps interface. – Lukasz Dynowski Mar 04 '21 at 15:52

1 Answers1

2

You need to set up a Docker Registry in project settings service connections. To do so follow below instructions:

  1. Go to https://dev.azure.com/my_username
  2. Click project that you working on.
  3. Click Project Settings - There should be a gear icon in down left corner on a web page.
  4. Click Service connections -In the middle of the page in Pipeline settings section.
  5. Click New service connection button - in upper right corner
  6. Select Docker Registry - click next
  7. Choose Docker Hub option as registry type.
  8. Provide Docker ID - docker hub username, password and set Service connection name to dockerHub.

enter image description here

Once this is done then you set dockerHub in Docker@2 task in yaml file. e.g. containerRegistry: dockerHub

Alternatively this method should work as well. Select the Docker registry service connection in the docker task:

enter image description here

enter image description here

Lukasz Dynowski
  • 11,169
  • 9
  • 81
  • 124
Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • BTW. I ended up following this [answer](https://stackoverflow.com/questions/41984399/denied-requested-access-to-the-resource-is-denied-docker#answer-41984666) in order to push my image to Docker Hub. – Lukasz Dynowski Mar 04 '21 at 15:55