Last active
February 12, 2019 09:07
-
-
Save codeinthehole/9ddca1df94bcdffce04b to your computer and use it in GitHub Desktop.
Bash functions for private Docker registries
This file contains hidden or 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
| # Add these functions to your ~/.bashrc in order to be able to query private | |
| # Docker registries from the commandline. You'll need the JQ library | |
| # (http://stedolan.github.io/jq/) to be installed. Alternatively, you can just | |
| # pipe to " python -mjson.tool" to get pretty JSON formatting | |
| # TODO Enter the correct details here | |
| DOCKER_REGISTRY_HOST=docker.yourcompany.com | |
| DOCKER_REGISTRY_AUTH=someuser:somepassword | |
| function _docker_fetch() { | |
| echo $1 | |
| curl -s --user $DOCKER_REGISTRY_AUTH $1 | jq '.' | |
| } | |
| # List repos (query string is optional) | |
| function docker_search() { | |
| _docker_fetch https://$DOCKER_REGISTRY_HOST/v1/search?q=$1 | |
| } | |
| # List tags for a repo | |
| function docker_tags() { | |
| _docker_fetch https://$DOCKER_REGISTRY_HOST/v1/repositories/$1/tags | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment