Skip to content

Instantly share code, notes, and snippets.

@codeinthehole
Last active February 12, 2019 09:07
Show Gist options
  • Select an option

  • Save codeinthehole/9ddca1df94bcdffce04b to your computer and use it in GitHub Desktop.

Select an option

Save codeinthehole/9ddca1df94bcdffce04b to your computer and use it in GitHub Desktop.
Bash functions for private Docker registries
# 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