Skip to content

Instantly share code, notes, and snippets.

@noqqe
Created May 9, 2022 14:30
Show Gist options
  • Save noqqe/fe3159ab45cf5fd871711571f35db777 to your computer and use it in GitHub Desktop.
Save noqqe/fe3159ab45cf5fd871711571f35db777 to your computer and use it in GitHub Desktop.
Shows ports that are used for your nexus instances docker repos
#!/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