Unable to login to private docker registry from Jenkins

12/29/2018

I am trying to use Jenkins to build and push docker images to private registry. However, while trying docker login command, I am getting this error:

http: server gave HTTP response to HTTPS client

I know that this might be happening because the private registry is not added as an insecure registry. But, how I can resolve this in CI pipeline?

Jenkins is set up on a Kubernetes cluster and I am trying to automate the deployment of an application on the cluster.

-- Shantanu Deshpande
docker
jenkins
kubernetes

1 Answer

12/29/2018

This has nothing to do with the Jenkins CI pipeline or Kubernetes. Jenkins will not be able to push your images until configure follow either of the below steps

You have two options here

1) Configure your docker client to use the secure registry over HTTPS. This will include setting up self signed certificates or getting certificates from your local certificate authority.

2) Second solution is to use your registry over an unencrypted HTTP connection. So if you are running docker on kubernetes. You will have to configure the daemon.json file in /etc/docker/daemon.json.

PS: This file might not exist. You will have to create it.

Then add in the below content. Make sure you change the url to match your docker registry

{
  "insecure-registries" : ["myregistrydomain.com:5000"]
}

Then restart docker using systemctl restart docker or etc/init.d/docker restart depending on the version of linux distro installed on your cluster

Let me know if you have any questions

-- Varun Babu Pozhath
Source: StackOverflow