Update Dockerhub repository description via API

36 Views Asked by At

I'm trying to update description in a Docker repository on hub.docker.com, where I'm the owner. Doing some search, I reached to the follow example:

#!/bin/bash

set -ex

DOCKER_USERNAME="uilianries"
DOCKER_PASSWORD="<Got from https://hub.docker.com/settings/security with read and write permission>"
REPOSITORY_NAME="doxygen"

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

REPO_DETAILS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${DOCKER_USERNAME}/${REPOSITORY_NAME}/)

curl -v -H "Authorization: JWT ${TOKEN}" -H "Content-Type: application/json" -X PATCH https://hub.docker.com/v2/repositories/${DOCKER_USERNAME}/${REPOSITORY_NAME}/ --data '{"description": "Testing", "full_description": "full description"}'

The response is:

+ DOCKER_USERNAME=uilianries
+ DOCKER_PASSWORD=*****************
+ REPOSITORY_NAME=doxygen
++ curl -s -H 'Content-Type: application/json' -X POST -d '{"username": "uilianries", "password": "*****************", "scopes": ["repository:modify"]}' https://hub.docker.com/v2/users/login/
++ jq -r .token
+ TOKEN=*****************
++ curl -s -H 'Authorization: JWT *****************' https://hub.docker.com/v2/repositories/uilianries/doxygen/
+ REPO_DETAILS='{"user":"uilianries","name":"doxygen","namespace":"uilianries","repository_type":"image","status":1,"status_description":"active","description":"","is_private":false,"is_automated":false,"star_count":0,"pull_count":20,"last_updated":"2018-09-16T18:40:33.381898Z","date_registered":"2018-09-16T18:40:32.913827Z","collaborator_count":0,"affiliation":"editor","hub_user":"uilianries","has_starred":false,"permissions":{"read":true,"write":true,"admin":true},"media_types":["application/vnd.docker.container.image.v1+json"],"content_types":["image"]}'
+ curl -v -H 'Authorization: JWT *****************' -H 'Content-Type: application/json' -X PATCH https://hub.docker.com/v2/repositories/uilianries/doxygen/ --data '{"description": "Testing", "full_description": "full description"}'
*   Trying 44.221.37.199:443...
* Connected to hub.docker.com (44.221.37.199) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=*.docker.com
*  start date: Oct  2 00:00:00 2023 GMT
*  expire date: Oct 31 23:59:59 2024 GMT
*  subjectAltName: host "hub.docker.com" matched cert's "*.docker.com"
*  issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M01
*  SSL certificate verify ok.
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
> PATCH /v2/repositories/uilianries/doxygen/ HTTP/1.1
> Host: hub.docker.com
> User-Agent: curl/7.81.0
> Accept: */*
> Authorization: JWT *****************
> Content-Type: application/json
> Content-Length: 66
> 
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
< date: Thu, 14 Dec 2023 13:09:38 GMT
< content-type: application/json
< content-length: 46
< 
{"message":"insufficient scope","errinfo":{}}
* Connection #0 to host hub.docker.com left intact

I can see using the generated Token I have read, write and admin permission. However, something is missing when trying to update the description, the return is:

HTTP 403: insufficient scope

No clue about, I'm the owner and have all access, but can not change my own repository?

0

There are 0 best solutions below