Skip to content

Instantly share code, notes, and snippets.

@ahmetb
Forked from tianon/speedtest-registry-directly.sh
Last active August 29, 2015 14:14
Show Gist options
  • Save ahmetb/af912cc764ec2c2ce45c to your computer and use it in GitHub Desktop.
Save ahmetb/af912cc764ec2c2ce45c to your computer and use it in GitHub Desktop.

Revisions

  1. @tianon tianon renamed this gist Nov 11, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @tianon tianon revised this gist Nov 11, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions test.sh
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@ image='tianon/speedtest'
    layer='b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f'
    # docker inspect b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f | grep '"Size"'
    # "Size": 580580561,
    # ("Content-Length: 228991341" though...)

    token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | awk -F ':[[:space:]]*|\r' '$1 == "X-Docker-Token" { print $2 }')"

  3. @tianon tianon revised this gist Nov 11, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion test.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,8 @@ set -e

    image='tianon/speedtest'
    layer='b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f'
    # <none> <none> b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f 10 weeks ago 670.7 MB
    # docker inspect b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f | grep '"Size"'
    # "Size": 580580561,

    token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | awk -F ':[[:space:]]*|\r' '$1 == "X-Docker-Token" { print $2 }')"

  4. @tianon tianon revised this gist Nov 11, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions test.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@ set -e

    image='tianon/speedtest'
    layer='b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f'
    # <none> <none> b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f 10 weeks ago 670.7 MB

    token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | awk -F ':[[:space:]]*|\r' '$1 == "X-Docker-Token" { print $2 }')"

  5. @tianon tianon revised this gist Nov 11, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test.sh
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,4 @@ layer='b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f'

    token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | awk -F ':[[:space:]]*|\r' '$1 == "X-Docker-Token" { print $2 }')"

    time curl -sSL -o /dev/null -D- -H "Authorization: Token $token" "https://registry-1.docker.io/v1/images/$layer/layer"
    time curl -sSL -o /dev/null -D- -H "Authorization: Token $token" "https://registry-1.docker.io/v1/images/$layer/layer"
  6. @tianon tianon revised this gist Nov 11, 2014. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions test.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    VICTIM=tianon/speedtest
    LAYER=b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f
    # LAYER=80da4fde3cb0d72261fcf67a713a016105dee9667cbc228c6973523c09681bf3
    SIGNATURE="`curl -iv -o/dev/null -H "X-Docker-Token: true" "https://registry.hub.docker.com/v1/repositories/$VICTIM/images" 2>&1 | awk '{print $3}' | grep signature | tr -d "\r\n"`"
    CF_URL="`curl -iv -o/dev/null -H "Authorization: Token $SIGNATURE" https://registry-1.docker.io/v1/images/$LAYER/layer 2>&1 | awk '{print $3}' | grep cloudfront | sed -e 's/\r\n//g' | tr -d "\r\n"`"
    #!/bin/bash
    set -e

    echo "Going to fetch: $CF_URL"
    time curl -iv -o/dev/null "${CF_URL}" 2>&1 | grep -wi "content-length\|x-cache"
    image='tianon/speedtest'
    layer='b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f'

    token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | awk -F ':[[:space:]]*|\r' '$1 == "X-Docker-Token" { print $2 }')"

    time curl -sSL -o /dev/null -D- -H "Authorization: Token $token" "https://registry-1.docker.io/v1/images/$layer/layer"
  7. @tianon tianon renamed this gist Nov 11, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt → test.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@
    CREDS=XXXX:YYYYY
    VICTIM=tianon/speedtest
    LAYER=b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f
    # LAYER=80da4fde3cb0d72261fcf67a713a016105dee9667cbc228c6973523c09681bf3
    SIGNATURE="`curl -iv -o/dev/null --basic -u $CREDS -H "X-Docker-Token: true" "https://registry.hub.docker.com/v1/repositories/$VICTIM/images" 2>&1 | awk '{print $3}' | grep signature | tr -d "\r\n"`"
    SIGNATURE="`curl -iv -o/dev/null -H "X-Docker-Token: true" "https://registry.hub.docker.com/v1/repositories/$VICTIM/images" 2>&1 | awk '{print $3}' | grep signature | tr -d "\r\n"`"
    CF_URL="`curl -iv -o/dev/null -H "Authorization: Token $SIGNATURE" https://registry-1.docker.io/v1/images/$LAYER/layer 2>&1 | awk '{print $3}' | grep cloudfront | sed -e 's/\r\n//g' | tr -d "\r\n"`"

    echo "Going to fetch: $CF_URL"
  8. @dmp42 dmp42 created this gist Sep 24, 2014.
    9 changes: 9 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    CREDS=XXXX:YYYYY
    VICTIM=tianon/speedtest
    LAYER=b31651d7665036bcf58a0b6b0d7aca173daff87b003ec50621cb0fde8d68864f
    # LAYER=80da4fde3cb0d72261fcf67a713a016105dee9667cbc228c6973523c09681bf3
    SIGNATURE="`curl -iv -o/dev/null --basic -u $CREDS -H "X-Docker-Token: true" "https://registry.hub.docker.com/v1/repositories/$VICTIM/images" 2>&1 | awk '{print $3}' | grep signature | tr -d "\r\n"`"
    CF_URL="`curl -iv -o/dev/null -H "Authorization: Token $SIGNATURE" https://registry-1.docker.io/v1/images/$LAYER/layer 2>&1 | awk '{print $3}' | grep cloudfront | sed -e 's/\r\n//g' | tr -d "\r\n"`"

    echo "Going to fetch: $CF_URL"
    time curl -iv -o/dev/null "${CF_URL}" 2>&1 | grep -wi "content-length\|x-cache"