404 when executing docker push to gitlab-container-registry
Asked Answered
V

3

11

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?

Variegate answered 27/7, 2020 at 20:32 Comment(2)
I have exactly the same issue.Celesta
gitlab_rails['registry_...'] are the settings for the omnibus nginx reverse proxy to the registry server (internally). registry[...] are the settings for the registry server (ensure registry['enables'] = true). nginx[...] are general settings for the omnibus nginx. external_url is the general server domain of the omnibus nginx.Raising
O
2

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.

Outrange answered 4/2, 2022 at 23:32 Comment(0)
M
0

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
Minier answered 11/3, 2023 at 13:52 Comment(0)
C
-1

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.

Chimb answered 7/12, 2021 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.