Skip to content

Instantly share code, notes, and snippets.

View nishakm's full-sized avatar
💭
maybe faster responses

nisha nishakm

💭
maybe faster responses
View GitHub Profile
@nishakm
nishakm / fetch_manifest_from_registry
Created March 31, 2021 22:11
Fetch manifest from registry
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
)
@nishakm
nishakm / gist:4c2d078ae6f8fa63c7733e0f3105dfd8
Created July 14, 2020 23:25
verifying downloaded digests
$ token="$(curl -fsSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/debian:pull" | jq --raw-output '.token')"
nisha@ubuntu ~ $ manifest="$(curl -fsSL -H "Authorization: Bearer $token" -H "Accept: application/vnd.docker.distribution.manifest.v2+json" "https://index.docker.io/v2/library/debian/manifests/sha256:e8bab439d86e39a0f694344ab0c11f77bce1460c13c903c437ee9da69c7b6fa3")"
nisha@ubuntu ~ $ echo $manifest | sha256sum
edb9b33918300be33fb87aa3b451493b94d0290edc9de95caae90f754996d0df -
@nishakm
nishakm / querying_docker_api_with_python_requests.txt
Last active July 15, 2020 19:44
Querying Docker API with python requests
>>> resp = requests.get("https://index.docker.io/v2/library/debian/manifests/bullseye")
>>> resp.headers
{'Content-Type': 'application/json', 'Docker-Distribution-Api-Version': 'registry/2.0', 'Www-Authenticate': 'Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:library/debian:pull"', 'Date': 'Mon, 13 Jul 2020 17:13:00 GMT', 'Content-Length': '157', 'Strict-Transport-Security': 'max-age=31536000'}
>>> token = requests.get("https://auth.docker.io/token", params={"service": "registry.docker.io", "scope":"repository:library/debian:pull"})
>>> token
<Response [200]>
>>> token.json()
{'token': 'eyJhbGciOiJS...
>>> manifest = requests.get("https://index.docker.io/v2/library/debian/manifests/bullseye", headers={'Authorization': 'Bearer ' + token.json()['token'], Accept='application/vnd.docker.distribution.manifest.v2+json'})
>>> manifest.text