使用docker注册表错误500设置gitlab

时间:2016-11-25 09:20:03

标签: docker gitlab docker-registry

我在example.domain.com

上使用docker注册表运行了docker
docker run -d -p 5000:5000 --restart=always --name registry \
-v /etc/ssl/certs/:/certs \
-e REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry \
-v /git/docker_registry:/var/lib/registry \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/server.key \
registry:2

我可以推送到这个docker注册表,但当我尝试使用example.domain.com config在同一台机器gitlab.yml上运行gitlab时连接它:

  registry:
    enabled: true
    host: example.domain.com
    port: 5005
    api_url: http://localhost:5000/
    key: /etc/ssl/certs/server.key
    path: /git/docker_registry

在Web浏览器中启用Docker注册表项目工作正常,但是当我转到项目页面并打开Regisry page时,我收到错误500

Gitlab日志显示:

Started POST "/api/v3/internal/allowed" for 10.10.200.96 at 2016-11-25 10:15:01 +0100
Started POST "/api/v3/internal/allowed" for 10.10.200.96 at 2016-11-25 10:15:01 +0100
Started POST "/api/v3/internal/allowed" for 10.10.200.96 at 2016-11-25 10:15:01 +0100
Started GET "/data-access-servicess/centipede-rest/container_registry" for 10.11.0.232 at 2016-11-25 10:15:01 +0100
Processing by Projects::ContainerRegistryController#index as HTML
  Parameters: {"namespace_id"=>"data-access-servicess", "project_id"=>"centipede-rest"}
Completed 500 Internal Server Error in 195ms (ActiveRecord: 25.9ms)

Faraday::ConnectionFailed (wrong status line: "\x15\x03\x01\x00\x02\x02"):
  lib/container_registry/client.rb:19:in `repository_tags'
  lib/container_registry/repository.rb:22:in `manifest'
  lib/container_registry/repository.rb:31:in `tags'
  app/controllers/projects/container_registry_controller.rb:8:in `index'
  lib/gitlab/request_profiler/middleware.rb:15:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'

和Docker Registry日志:

2016/11/25 09:15:01 http: TLS handshake error from 172.17.0.1:44608: tls: first record does not look like a TLS handshake

1 个答案:

答案 0 :(得分:2)

问题是gitlab尝试通过http而不是httpS连接到注册表。因此,您正在收到TLS握手错误。

更改你的gitlab配置
registry:
  api_url: http://localhost:5000/

registry:
  api_url: https://localhost:5000/

如果您使用的是自签名证书,请不要忘记在安装了gitlab的计算机上信任它。见 - > https://docs.docker.com/registry/insecure/#troubleshooting-insecure-registry