Registry with hostname - x509: certificate signed by unknown authority

I run Docker Desktop on my Linux PC. I want to use my raspberry pi as a docker registry, using it’s name (rpi.home) when pushing (instead of its IP address). I also want to connect via https. Following this guide: Test an insecure registry

My steps on my raspberry pi:

  1. mkdir certs
  2. openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -addext "subjectAltName = DNS:rpi.home" -x509 -days 365 -out certs/domain.crt
  3. docker run -d --restart=always --name registry -v $HOME/certs:/certs -e REGISTRY_HTTP_ADDR= -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key -p 443:443 registry

My steps on my Linux PC:

  1. scp pi@rpi.home:certs/domain.crt ca.crt
  2. sudo mkdir -p /etc/docker/certs.d/rpi.home/
  3. sudo cp ca.crt /etc/docker/certs.d/rpi.home/

After these steps, I would expect that I can push to the registry using docker push:
docker push rpi.home/test-image

However, I get this error:

Using default tag: latest
The push refers to repository [rpi.home/test-image]
Get "https://rpi.home/v2/": x509: certificate signed by unknown authority

How can I fix this error?

you can try below to push to your own repo

  1. add below content to /etc/docker/daemon.json in docker host machine
    "insecure-registries" : [ "rpi.home:port" ]
  1. then restart docker
sudo systemctl daemon-reload
sudo systemctl restart docker