Skip to content

Instantly share code, notes, and snippets.

@michaelneu
Created April 3, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelneu/01b1ff7b06d77cfa4669bc6c14711656 to your computer and use it in GitHub Desktop.
Save michaelneu/01b1ff7b06d77cfa4669bc6c14711656 to your computer and use it in GitHub Desktop.
Fetch all tags from a Docker image
#!/usr/bin/env python3
import requests
import sys
if __name__ == "__main__":
if len(sys.argv) != 2:
print("usage: python3 docker-tags.py IMAGE")
exit(1)
image = sys.argv[1]
if "/" not in image:
image = "library/" + image
url = "https://registry.hub.docker.com/v2/repositories/%s/tags/" % image
page = 1
tags = []
while url:
print("[*] fetching page", page)
response = requests.get(url)
json = response.json()
tags += [tag.get("name", "") for tag in json.get("results", [])]
url = json.get("next", False)
page += 1
print("\n".join(sorted(tags)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment