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

<pre><code>http: server gave HTTP response to HTTPS client
</code></pre>

<p>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?</p>

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

<p>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</p>

<p>You have two options here</p>

<p>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.</p>

<p>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 <code>daemon.json</code> file in <code>/etc/docker/daemon.json</code>. </p>

<p>PS: This file might not exist. You will have to create it.</p>

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

<pre><code>{
  "insecure-registries" : ["myregistrydomain.com:5000"]
}
</code></pre>

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

<p>Let me know if you have any questions</p>
