LoginSignup
2
1

More than 3 years have passed since last update.

werckerでエラー「You have reached your pull rate limit.」

Posted at

背景

会社で使用しているデプロイ用で使っている無料CIの中でwerckerがあります。無料なのでちょっと不便なところやトリガーが動かない等の問題点も有りましたが使い続けていました。

最近になって以下のエラーが出る頻度が多くて困りまして、調査&対応を纏めて見ました。

エラー

エラー内容は以下のような物でした。

fetch failed to pull image *****: API error (500): {"message":"toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit"}

最初なんだこれ!!って感じでした。よくよく調べると認識してなかったですが、無料でPullする回数の制限が掛かったわけです。
参考:https://www.docker.com/blog/what-you-need-to-know-about-upcoming-docker-hub-rate-limiting/

制限

pull時のダウンロード比率の制限が11月2日から変更となったとのことです。

  • 認証していない(anonymous ユーザ)場合は、100ダウンロード/6時間
  • 認証している場合(Free アカウント)は 200 ダウンロード/6時間
  • Docker Pro / Team 有償アカウントでログイン時は無制限

参考:https://www.docker.com/blog/scaling-docker-to-serve-millions-more-developers-network-egress/

確認

実際あっているか確認をして見ました。必要なツールは以下の二つが必要なので、インストールしてください。
- curl
- jq

参考:https://www.docker.com/blog/checking-your-current-docker-pull-rate-limits-and-status/

認証なし

こちらは基本IPで判断するらしいです。認証なし使用するTokenの取得します。

$ TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)

上記で取得したTokenを利用して現在使用率を確認します。

$ curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit

< RateLimit-Limit: 100;w=21600
< RateLimit-Remaining: 99;w=21600

RateLimit-Limit:最大Pull回数(6時間)
RateLimit-Limit:残りPull回数(6時間)

認証有り:無料ユーザー

こちらはアカウント別で管理されるようです。同じくTokenを取得します。

$ TOKEN=$(curl --user '{{username}}:{{password}}' "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)

上記の「{{username}}:{{password}}」のところ実際お持ちしているアカウント情報を入れてください。

上記で取得したTokenを利用して現在使用率を確認します。

$ curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit

< RateLimit-Limit: 200;w=21600
< RateLimit-Remaining: 197;w=21600

こんな感じで確認しました。

Werckerの対応

デプロイ設定ファイルは以下の感じでした。

修正前

box: {{dockerイメージのID}}
no-response-timeout: 25
build:
  steps:
    - script:

    ・・・・・・・

見てみましょう!実際dockerhubからpullする際にアカウント情報がとこにもないです。結論としては全ユーザーがwerckerで使用しているIP三つで100回ずつ300回を使い分けている感じですね。

確かにこれは大問題ですね〜〜〜

修正後

参考:https://devcenter.wercker.com/administration/containers/private-containers/

box:
  id: {{dockerイメージのID}}
  username: {{username}}
  password: {{password}}
  tag: latest
no-response-timeout: 25
build:
  steps:
    - script:

    ・・・・・・・

これで一応持っているアカウントの200回をこの設定をしているプロジェクトのデプロイが使えることになります。。。。。本当かな? どこにもそんな記事もないし。

確認方法

実際アカウントを設定に入れてwerckerによるデプロイが行った後に上記の「認証有り:無料ユーザー」を実行すれば「RateLimit-Remaining」が減って来るので確認できます。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1