Azure Batch - problem with Docker Hub private repository

Matteo Grimaldi 1 Reputation point
2020-11-19T15:02:38.45+00:00

In Azure Batch, I create a Pool with “prefetch images for container configuration” according to the instructions of

https://video2.skills-academy.com/en-us/azure/batch/batch-docker-container-workloads#container-configuration-for-batch-pool

Firstly, I used an image from Azure Container Registry, it works.

Then I used an image from Docker Hub page (the repository is public), it works. Previously I uploaded the image by publishing my project in Visual Studio to Docker Hub. Setting the container registry of the Pool, I had to change the registryServer, “https://hub.docker.com” does not work for me, I changed it to “https://registry.hub.docker.com” and this works.

Then, in Docker Hub, I changed the repository from public to private, and now the Pool does not work. Now, when I start the Pool, the Node has the error

Code:ContainerInvalidImage
Message:
One or more container images specified are invalid
Values:
ContainerImage - xxx/yyy:latest
Message - pull access denied for xxx/yyy, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

I understand that since the Docker Hub repository is private the Pool needs the credentials to login, but actually I set the correct username and password in the Pool container registry. The container image name also is surely correct because is the same of the previous attempt. So what is the problem? Can Azure Batch pull a private Docker Hub repository?

Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
320 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. whoward-msft 2,766 Reputation points
    2020-11-21T00:11:31.987+00:00

    Hey @Matteo Grimaldi ,

    Yes you can pull from a private registry. All you need to do is to specify your username and password when configuring the registry. See the ContainerRegistry Class here. Based off the error your receiving your username and password aren't configured correctly. If you continue to have trouble I'd suggest Azure Container Registry as it offers the same features of Docker Hub at a similar price.


  2. Matteo Grimaldi 1 Reputation point
    2020-11-23T13:48:17.597+00:00

    I set the correct username and password in ContainerRegistry, but does not work.
    To reproduce the problem at your side, I created a new test account in DockerHub site (don’t worry for me, it is only a test account to solve this problem). Log in at https://hub.docker.com/ with:
    Username:
    grimaldidockerid
    Password:
    abcdefg.1

    you will see the private repository “grimaldidockerid/algorithmfake”. I uploaded it by publishing my project in Visual Studio to Docker Hub.
    Then try to create a Pool in Azure Batch, I hope you already have a test account in Azure! In Azure Batch, try the following steps:

    • In “Pools” section, click “Add”
    • Enter a “Pool ID” (whatever)
    • As “Publisher” set “microsoft-azure-batch”
    • As “Offer” set “ubuntu-server-container”
    • As “Sku” set “16-04-lts”
    • In “Container configuration” click “Custom”
    • As “Container image names” set “grimaldidockerid/algorithmfake:latest”
    • In “Container registries” add a new item with: “Registry username”=”grimaldidockerid”, “Password”=”abcdefg.1”, “Registry server”=”https://registry.hub.docker.com” (of course all without quotes)
    • As “Target dedicated nodes” set 1
    • Click “OK” at the bottom

    After few minutes you will see that the created Node of the Pool has the error I wrote in my previous message. Now, if you change the repository in DockerHub from Private to Public (in the “Settings” tab, “Visibility Settings”, “Make public”) and repeat the above steps in Azure Batch, you will see that the created Node has no error (State=Idle).
    So, what’s wrong in what I did? For your test, feel free to change the visibility of the repository in DockerHub.

    0 comments No comments

  3. Matteo Grimaldi 1 Reputation point
    2020-11-27T15:05:14.387+00:00

    Any news? Have you been able to reproduce the problem? It takes only a few minutes.

    0 comments No comments

  4. Arun N 1 Reputation point
    2021-04-17T14:57:05.41+00:00

    I can confirm that I am seeing the exact same issues.

    Azure batch integration with dockerhub works fine for public repositories (registry URL: index.docker.io), however, this does not work when that same dockerhub repo is converted to private

    0 comments No comments