2015-05-23 42 views
2

我得到下面的錯誤(見下文執行命令):搬運工運行註冊表錯誤301響應丟失Location頭

DEBU[0000] using "text" logging formatter    
panic: Get : 301 response missing Location header 

goroutine 1 [running]: 
github.com/docker/distribution/registry/handlers.NewApp(0x7f5f7ba3eab8, 0xc2080cf1a0, 0xc20802b8a0, 0x3, 0xc20802b8d8, 0x5, 0xc20802b908, 0x4, 0xc2080ce720, 0xa5e630, ...) 
    /go/src/github.com/docker/distribution/registry/handlers/app.go:81 +0x5eb 
main.main() 
    /go/src/github.com/docker/distribution/cmd/registry/main.go:62 +0x439 

goroutine 6 [syscall]: 
os/signal.loop() 
    /usr/src/go/src/os/signal/signal_unix.go:21 +0x1f 
created by os/signal.init·1 
    /usr/src/go/src/os/signal/signal_unix.go:27 +0x35 

goroutine 10 [runnable]: 
net/http.(*persistConn).readLoop(0xc20809d6b0) 
    /usr/src/go/src/net/http/transport.go:928 +0x9ce 
created by net/http.(*Transport).dialConn 
    /usr/src/go/src/net/http/transport.go:660 +0xc9f 

goroutine 17 [syscall, locked to thread]: 
runtime.goexit() 
    /usr/src/go/src/runtime/asm_amd64.s:2232 +0x1 

goroutine 11 [select]: 
net/http.(*persistConn).writeLoop(0xc20809d6b0) 
    /usr/src/go/src/net/http/transport.go:945 +0x41d 
created by net/http.(*Transport).dialConn 
    /usr/src/go/src/net/http/transport.go:661 +0xcbc 

我開始搬運工註冊表如下:

docker run \ 
    --rm -it \ 
    --env="REGISTRY_STORAGE_S3_ACCESSKEY=SECRET_KEY" \ 
    --env="REGISTRY_STORAGE_S3_SECRETKEY=ACCESS_KEY" \ 
    --env="REGISTRY_STORAGE_S3_BUCKET=bucket" \ 
    --env="REGISTRY_HTTP_TLS_CERTIFICATE=/go/src/github.com/docker/distribution/certs/domain.crt" \ 
    --env="REGISTRY_HTTP_TLS_KEY=/go/src/github.com/docker/distribution/certs/domain.key" \ 
    --env="REGISTRY_HTTP_ADDR=localhost:5000" \ 
    --name="registry" \ 
    --publish="5000:5000" \ 
    --volume="/sandbox/docker/certs:/go/src/github.com/docker/distribution/certs" \ 
    --volume="/sandbox/docker/registry/config.yml:/go/src/github.com/docker/distribution/cmd/registry/config.yml" \ 
    distribution/registry cmd/registry/config.yml 

其中REGISTRY_STORAGE_S3_ACCESSKEYREGISTRY_STORAGE_S3_SECRETKEYREGISTRY_STORAGE_S3_BUCKET出於安全原因保持虛擬值。我能夠使用它們寫入\從所需的s3桶中讀取。

這裏有一些更多的信息:

$ docker info 
Containers: 0 
Images: 109 
Storage Driver: aufs 
Root Dir: /var/lib/docker/aufs 
Backing Filesystem: extfs 
Dirs: 109 
Dirperm1 Supported: false 
Execution Driver: native-0.2 
Kernel Version: 3.13.0-53-generic 
Operating System: Ubuntu 14.04.2 LTS 
CPUs: 4 
Total Memory: 15.54 GiB 
Name: heaven 
ID: REMOVED_FOR_SECURITY_REASONS 
WARNING: No swap limit support 

目錄結構:

$ ls -R /sandbox/docker 
/sandbox/docker/certs: 
domain.crt 
domain.key 

/sandbox/docker/registry: 
config.yml 

config.yml文件:

$ cat /sandbox/docker/registry/config.yml 
version: 0.1 
log: 
    level: debug 
    formatter: text 
    fields: 
     service: registry 
     environment: prod 
storage: 
    s3: 
     accesskey: awsaccesskey 
     secretkey: awssecretkey 
     region: us-west-1 
     bucket: bucket 
     encrypt: true 
     secure: true 
     v4auth: true 
     chunksize: 5242880 
     rootdirectory: /s3/object/name/prefix 
    cache: 
     layerinfo: inmemory 
auth: 
    token: 
     realm: token-realm 
     service: token-service 
     issuer: registry-token-issuer 
     rootcertbundle: /root/certs/bundle 
http: 
    addr: localhost:5000 
    secret: myspecialsecret 
    tls: 
     certificate: /go/src/github.com/docker/distribution/certs/domain.crt 
     key: /go/src/github.com/docker/distribution/certs/domain.key 
    debug: 
     addr: localhost:5001 

認證文件:

$ grep -r "^----" /sandbox/docker/certs/ 
/sandbox/docker/certs/domain.crt:-----BEGIN CERTIFICATE----- 
/sandbox/docker/certs/domain.crt:-----END CERTIFICATE----- 
/sandbox/docker/certs/domain.crt:-----BEGIN CERTIFICATE----- 
/sandbox/docker/certs/domain.crt:-----END CERTIFICATE----- 
/sandbox/docker/certs/domain.key:-----BEGIN CERTIFICATE----- 
/sandbox/docker/certs/domain.key:-----END CERTIFICATE----- 

其中domain.crt也包含中間證書(連接在底部)。

任何人都可以請指出什麼是錯的?

我知道我可以建立一個新的註冊表映像,如docker docs所示,但我想只用docker run而不用docker build

回答

2

這被稱爲當配置文件中指定了錯誤的S3區域發生。在這裏看到類似的報告:https://github.com/docker/distribution/issues/854

+0

配置文件中的S3區域必須與最初創建存儲區的S3區域匹配,否則註冊表將使用錯誤的URL並從AWS獲得301重定向。 – jonatan