Cannot login docker with self-signed certificate

I have built GitLab and Container Registry using a self-signed certificate.
The docker login is failing.

$ docker login [hostname]:4567
Username: 
Password: 
Error response from daemon: Get "https://[hostname]:4567/v2/": x509: certificate signed by unknown authority

Create self-signed certificate

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/gitlab/ssl/[hostname].key -addext "subjectAltName = DNS:[hostname]" -out /etc/ gitlab/ssl/[hostname].crt

Edit gitlab.rb

$ diff gitlab.rb gitlab.rb.org 
32c32
< external_url 'https://[hostname]'
---
> external_url 'http://[hostname]'
798d797
< registry_external_url 'https://[hostname]:4567'
1426d1424
< nginx['redirect_http_to_https'] = true 
2005d2002
< registry_nginx['listen_port'] = 4567
2526d2522
< letsencrypt['enable'] = false

Copy crt file in /etc/docker/cert.d/[hostname]:4567 directory.

$ ls -l /etc/docker/cert.d/[hostname]:4567/ca.crt 

Please let me know if there are any mistakes or missing steps.

Reference link:.

Edit /etc/docker/daemon.json and put:

{
    "insecure-registries" : [ "hostname:4567" ]
}

and restart docker service.

if you are using HTTP or self-signed certificates, you need to set insecure-registries.

It worked!
Thanks.

1 Like