Skip to content

Instantly share code, notes, and snippets.

@ydp
Created March 26, 2018 02:30
Show Gist options
  • Save ydp/58cadd91a35e28f316d0995b62429f91 to your computer and use it in GitHub Desktop.
Save ydp/58cadd91a35e28f316d0995b62429f91 to your computer and use it in GitHub Desktop.
list tags for image in docker hub
#!/bin/bash
if [ $# -lt 1 ]
then
cat << HELP
dockertags -- list all tags for a Docker image on a remote registry.
EXAMPLE:
- list all tags for ubuntu:
dockertags ubuntu
- list all php tags containing apache:
dockertags php apache
HELP
fi
image="$1"
tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'`
if [ -n "$2" ]
then
tags=` echo "${tags}" | grep "$2" `
fi
echo "${tags}"
#!/bin/bash
image="tensorflow/tensorflow"
for i in `sh dockertags.sh $image`
do
docker pull $image":"$i
docker tag $image":"$i "registry.api.weibo.com/tf/tensorflow:"$i
docker push "registry.api.weibo.com/tf/tensorflow:"$i
done
@ydp
Copy link
Author

ydp commented Mar 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment