1

I'm working on a Python 3.6 project in which I need to create a repository on the docker hub account by using API. I have googled a lot but couldn't find any API client to create repositories on docker hub account.

I have found only this module dockercloud from here and tried it in this way:

dockercloud.user = 'arycloud'
dockercloud.apikey = 'API_KEY'
print(client.Repository.list())

But it returns an error like this:

dockercloud.api.exceptions.AuthError: error getting credentials - err: exec: "docker-credential-osxkeychain": executable file not found in $PATH, out: ``

Is there any way to create a repo on Docker Hub using API?

Rafael Tavares
  • 5,678
  • 4
  • 32
  • 48
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150

1 Answers1

0

The API documentation does not describe any mechanism for creating repositories on any registry, Docker Hub included.

However, I was able to create a repository using curl to send a POST request:

TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)

curl -s -H "Authorization: JWT ${TOKEN}" "https://hub.docker.com/v2/repositories/" \
     --data 'description=test' \
     --data 'full_description=full-description' \
     --data 'is_private=false' \
     --data 'name=test' \
     --data "namespace=${UNAME}"
starfry
  • 9,273
  • 7
  • 66
  • 96