请试试这个
function docker_tag_exists() { curl --silent -f -lSL https://index.docker.io/v1/repositories/$1/tags/$2 > /dev/null}if docker_tag_exists library/nginx 1.7.5; then echo existelse echo not existsfi更新:
如果使用Docker Registry
v2(基于此):
# set username and passwordUNAME="user"UPASS="password"function docker_tag_exists() { TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token) EXISTS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/$1/tags/?page_size=10000 | jq -r "[.results | .[] | .name == "$2"] | any") test $EXISTS = true}if docker_tag_exists library/nginx 1.7.5; then echo existelse echo not existsfi


