CaptnHirni
CaptnHirni

Reputation: 157

404 when executing docker push to gitlab-container-registry

I have installed gitlab-ce 13.2.0 on my server and the container-registry was immediately available.

from a other sever (or my local machine) I can login, but when pushing a image to the container-registry I get a 404-error: error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "<!DOCTYPE html>\n<html>\n<head>...

in my gitlab.rb I have:

external_url 'https://git.xxxxxxxx.com'
nginx['enable'] = true
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true

nginx['ssl_certificate'] = "/etc/gitlab/trusted-certs/xxxxxxxx.com.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/trusted-certs/xxxxxxxx.com.key"
nginx['ssl_protocols'] = "TLSv1.1 TLSv1.2"

registry_external_url 'https://git.xxxxxxxx.com'

what is confusing, is that the registry_external_url is the same as the external_url. There are those lines in the gitlab.rb:

### Settings used by GitLab application
# gitlab_rails['registry_enabled'] = true
# gitlab_rails['registry_host'] = "git.xxxxxxxx.com"
# gitlab_rails['registry_port'] = "5005"
# gitlab_rails['registry_path'] = "/var/opt/gitlab/gitlab-rails/shared/registry"

But when I uncomment this, I cannot login.

what can be the problem here?

Upvotes: 11

Views: 6887

Answers (3)

Kamelj
Kamelj

Reputation: 156

You should make sure you are using the right port:

registry_external_url = "https://gitlab.*****.com:5050"
registry_nginx['enable'] = true
registry_nginx['listen_https'] = true
registry_nginx['redirect_http_to_https'] = true
gitlab_rails['registry_enabled'] = true
gitlab_rails['registry_host'] = "gitlab.*****.com"
gitlab_rails['registry_port'] = "5050"

and the system listening to that port; when you run netstat -tunlp

tcp        0      0 0.0.0.0:5050            0.0.0.0:*               LISTEN      708263/nginx: maste 

And from client where you want to push the image:

docker login gitlab.*****.com:5050
docker build -t gitlab.*****.com:5050/frontend/app:1.0 .
docker push gitlab.*****.com:5050/frontend/app:1.0

Upvotes: 0

Salehi
Salehi

Reputation: 392

This is actually because you are using https port without proxying the registry in nginx.

Fix these lines according to the following in gitlab.rb:

registry_nginx['enable'] = true
registry_nginx['listen_https'] = true
registry_nginx['redirect_http_to_https'] = true
registry_external_url 'https://registry.YOUR_DOMAIN.gtld'

You don't need to touch nginx['ssl_*] parameters when you are using letsencrypt since the chef would take care.

Upvotes: 2

xy2
xy2

Reputation: 566

How is your image named? Your image name must match exactly not only the registry URL, but project too.

You can't just build "myimage:latest" and push it. It must be like git.xxxxxxxx.com/mygroup/myproject:latest. You can obtain correct name from $CI_REGISTRY_IMAGE predefined variable.

Upvotes: -1

Related Questions