docker-archive / docker-registry

This is **DEPRECATED**! Please go to https://github.com/docker/distribution
Apache License 2.0
2.88k stars 877 forks source link

docker registry redirecting to URLs with trailing slashes #976

Closed kbrowder closed 9 years ago

kbrowder commented 9 years ago

when i do a docker pull it does a GET from something like http://localhost:5000/v1/repositories/centos/images

However docker-registry sends a 301 to http://localhost:5000/v1/repositories/centos/images/ (with the trailing slash), this then proceeds to get HTTP 400/405, i assume this is because the correct url in index.docker.io is https://index.docker.io/v1/repositories/centos/images (without the trailing slash).

In any case I can't pull over localhost:5000 (or remotely over ssl with nginx the same error show in the access logs). Assistance would be appreciated.

Am I doing something wrong?

dmp42 commented 9 years ago

Do you use nginx or apache in front of your registry?

kbrowder commented 9 years ago

nginx, however the failure is the same when accessing port 5000 (eg accessing the docker registry dock directly).

dmp42 commented 9 years ago

Can you send the output of:

kbrowder commented 9 years ago

my docker version is 1.3.2 gotten from EPEL for centos 6, I don't have access to the machine right now, I'll get the rest of the data when I get back to the office. However i poked at it for a bit before I left and see the following behavior difference between index.docker.io and docker index:

And in the docker index:

Thanks in advance for for the help

dmp42 commented 9 years ago

Did you set STANDALONE=false ? Additionally to the requested info, can you copy your registry config if you are using a custom config?

kbrowder commented 9 years ago

I did, and I checked the the headers on http://localhost:5000/_ping, X-Docker-Registry-Standalone: mirror, I did configs via -e (env vars) only, it'll probably be tomorrow AM before I get back to the office and grab the full info above.

dmp42 commented 9 years ago

cc @shin- mirroring stuff, can use your savvy-ness :-)

kbrowder commented 9 years ago

docker info:

Containers: 4
Images: 77
Storage Driver: devicemapper
 Pool Name: docker-253:0-1703803-pool
 Pool Blocksize: 65.54 kB
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 3.757 GB
 Data Space Total: 107.4 GB
 Metadata Space Used: 5.292 MB
 Metadata Space Total: 2.147 GB
 Library Version: 1.02.89-RHEL6 (2014-09-01)
Execution Driver: native-0.2
Kernel Version: 2.6.32-504.1.3.el6.x86_64
Operating System: <unknown>

docker version:

Client version: 1.3.2
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 39fa2fa/1.3.2
OS/Arch (client): linux/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa/1.3.2

docker registry launch:

 /usr/bin/docker run -e STANDALONE=false -e MIRROR_SOURCE=https://registry-1.docker.io -e MIRROR_SOURCE_INDEX=https://index.docker.io -e SETTINGS_FLAVOR=local -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e SQLALCHEMY_INDEX_DATABASE=sqlite:////opt/sqlitedbs/registry.db -v /opt/sqlitedbs:/opt/sqlitedbs  registry:latest

Although to make things simpler (using the defaults) I've also tried:

/usr/bin/docker run -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e SQLALCHEMY_INDEX_DATABASE=sqlite:////opt/sqlitedbs/registry.db -v /opt/sqlitedbs:/opt/sqlitedbs registry:latest

Logs from docker-registry after a docker pull localhost:5000/centos:

$ docker attach 1e1

172.17.42.1 - - [27/Mar/2015:12:33:56 +0000] "GET /v1/_ping HTTP/1.1" 200 1438 "-" "Go 1.1 package http"
27/Mar/2015:12:33:56 +0000 DEBUG: args = {'namespace': 'library', 'repository': u'centos'}
27/Mar/2015:12:33:56 +0000 DEBUG: api_error: images not found
172.17.42.1 - - [27/Mar/2015:12:33:56 +0000] "GET /v1/repositories/centos/images HTTP/1.1" 404 29 "-" "docker/1.3.2 go/go1.3.3 kernel/2.6.32-504.1.3.el6.x86_64 os/linux arch/amd64"

Here's most of the logs after everything's started from docker after the aforementioned docker pull when running with -D:

[0eba0de5] -job container_inspect(917) = ERR (1)
[error] server.go:1207 Handler for GET /containers/{name:.*}/json returned error: No such container: 917
[error] server.go:110 HTTP Error: statusCode=404 No such container: 917
[debug] server.go:1181 Calling GET /containers/json
[info] GET /v1.15/containers/json
[0eba0de5] +job containers()
[0eba0de5] -job containers() = OK (0)
[debug] server.go:1181 Calling GET /containers/{name:.*}/json
[info] GET /v1.15/containers/1/json
[0eba0de5] +job container_inspect(1)
No such container: 1
[0eba0de5] -job container_inspect(1) = ERR (1)
[error] server.go:1207 Handler for GET /containers/{name:.*}/json returned error: No such container: 1
[error] server.go:110 HTTP Error: statusCode=404 No such container: 1
[debug] server.go:1181 Calling GET /containers/{name:.*}/json
[info] GET /v1.15/containers/1e1/json
[0eba0de5] +job container_inspect(1e1)
[0eba0de5] -job container_inspect(1e1) = OK (0)
[debug] server.go:1181 Calling POST /containers/{name:.*}/attach
[info] POST /v1.15/containers/1e1/attach?stderr=1&stdout=1&stream=1
[0eba0de5] +job container_inspect(1e1)
[0eba0de5] -job container_inspect(1e1) = OK (0)
[0eba0de5] +job attach(1e1)
[debug] attach.go:176 attach: stdout: begin
[debug] attach.go:215 attach: stderr: begin
[debug] attach.go:263 attach: waiting for job 1/2
[debug] server.go:1181 Calling POST /images/create
[info] POST /v1.15/images/create?fromImage=localhost%3A5000%2Fcentos%3Alatest
[0eba0de5] +job pull(localhost:5000/centos, latest)
[debug] endpoint.go:59 Error from registry "https://localhost:5000/v1/" marked as insecure: Get https://localhost:5000/v1/_ping: EOF. Insecurely falling back to HTTP
[debug] endpoint.go:144 RegistryInfo.Version: ""
[debug] endpoint.go:147 Registry standalone header: 'True'
[debug] endpoint.go:155 RegistryInfo.Standalone: true
[debug] session.go:266 [registry] Calling GET http://localhost:5000/v1/repositories/centos/images
[debug] http.go:162 http://localhost:5000/v1/repositories/centos/images -- HEADERS: map[User-Agent:[docker/1.3.2 go/go1.3.3 kernel/2.6.32-504.1.3.el6.x86_64 os/linux arch/amd64]]
Error: image centos not found
[0eba0de5] -job pull(localhost:5000/centos, latest) = ERR (1)
kbrowder commented 9 years ago

@dmp42, now I understand, STANDALONE=true is actually what it should be for my use case, sorry about the PEBKAC. Now i just can't get to the tags repo, looks like that's an easy thing to fix. Anyways this was a false alarm, apologies again.

dmp42 commented 9 years ago

Happy you figured it out. It can be confusing :)