Created
May 9, 2022 14:30
-
-
Save noqqe/fe3159ab45cf5fd871711571f35db777 to your computer and use it in GitHub Desktop.
Shows ports that are used for your nexus instances docker repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Usage | |
# ./show-docker-ports.py https://adminuser:[email protected] | |
import sys | |
import json | |
import requests | |
base_url=sys.argv[1] | |
repolist=base_url + '/service/rest/v1/repositories/' | |
rl = json.loads(requests.get(repolist).content) | |
for repo in rl: | |
if repo["format"] == 'docker': | |
repourl = base_url + "/service/rest/v1/repositories/docker/" + repo["type"] + "/" + repo["name"] | |
detail = json.loads(requests.get(repourl).content) | |
if detail["docker"]["httpPort"] is not None: | |
print(detail["docker"]["httpPort"], detail["name"], "http") | |
if detail["docker"]["httpsPort"] is not None: | |
print(detail["docker"]["httpsPort"], detail["name"], "https") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment