s_tajima:TechBlog

渋谷で働くインフラエンジニアのTechブログです。

dockerの検証: docker registryが起動しない

docker registry(https://github.com/docker/docker-registry)の検証のため、
Quick startに書かれている通り docker runをしてみた。

# docker run -e SETTINGS_FLAVOR=s3 \
>         -e AWS_REGION=ap-northeast-1 \
>         -e AWS_BUCKET=<MY_BUCKET_NAME> \
>         -e STORAGE_PATH=/registry \
>         -e AWS_KEY=XXX \
>         -e AWS_SECRET=XXX \
>         -e LOGLEVEL=debug \
>         -p 5000:5000 \
>         registry
2014-11-27 05:51:49,409 WARNING: Cache storage disabled!
2014-11-27 05:51:49,410 WARNING: LRU cache disabled!
2014-11-27 05:51:49,760 DEBUG: Will return docker-registry.drivers.s3.Storage
2014-11-27 05:51:49,774 DEBUG: Using access key provided by client.
2014-11-27 05:51:49,774 DEBUG: Using secret key provided by client.
2014-11-27 05:51:49,776 DEBUG: path=/
2014-11-27 05:51:49,776 DEBUG: auth_path=/<MY_BUCKET_NAME>/
2014-11-27 05:51:49,777 DEBUG: Method: HEAD
2014-11-27 05:51:49,777 DEBUG: Path: /
2014-11-27 05:51:49,777 DEBUG: Data:
2014-11-27 05:51:49,778 DEBUG: Headers: {}
2014-11-27 05:51:49,779 DEBUG: Host: <MY_BUCKET_NAME>.s3-ap-northeast-1.amazonaws.com
2014-11-27 05:51:49,779 DEBUG: Port: 443
2014-11-27 05:51:49,779 DEBUG: Params: {}
2014-11-27 05:51:49,780 DEBUG: establishing HTTPS connection: host=<MY_BUCKET_NAME>.s3-ap-northeast-1.amazonaws.com, kwargs={'port': 443, 'timeout': 70}
2014-11-27 05:51:49,781 DEBUG: Token: None
2014-11-27 05:51:49,781 DEBUG: StringToSign:
HEAD

Thu, 27 Nov 2014 05:51:49 GMT
/<MY_BUCKERT_NAME>/
2014-11-27 05:51:49,782 DEBUG: Signature:
AWS SIGNATURE

この状態で、ホストマシンからcurlをしてみるもEmpty reply.

# curl http://localhost:5000/v1/_ping
curl: (52) Empty reply from server

docker-registryを動かしているgunicornがLISTENしているところまでいっていない模様。
この時利用しているdocker image IDは "e42d15ec8417"
docker-registryのversionは"0.8.0"

調べてみるとこんなIssueがあった。

S3 Region · Issue #400 · docker/docker-registry · GitHub

Following is the problem I noticed with 0.7.0 When I specify s3_region as us-west-2 in my config, registry is up but I cannot pull or push.

If I comment out s3_region then everything is fine. I have confirmed on S3 that the region of my bucket is us-west-2

s3_regionを指定しているとうまく動かないらしい。
このIssueを読み進めていくと、状況としては似たようなことになっている。

色々と議論がされているが、結論としては

This looks like a gevent bug dealing with unicode.

Fixes issue with s3/boto/gevent hanging. by chuegle · Pull Request #670 · docker/docker-registry · GitHub
このコミットで解消している模様。
取り急ぎはここに書いてあるsed

# sed -i 's/import gevent.monkey/u"test".encode("idna")\nimport gevent.monkey/' /usr/local/lib/python2.7/dist-packages/docker_registry/drivers/s3.py

の通りに対応して回避。