简体   繁体   English

无法从Jenkins登录到私有Docker注册表

[英]Unable to login to private docker registry from Jenkins

I am trying to use Jenkins to build and push docker images to private registry. 我正在尝试使用Jenkins来构建docker镜像并将其推送到私有注册表。 However, while trying docker login command, I am getting this error: 但是,在尝试docker login命令时,出现此错误:

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? 但是,如何在CI管道中解决此问题?

Jenkins is set up on a Kubernetes cluster and I am trying to automate the deployment of an application on the cluster. Jenkins是在Kubernetes集群上设置的,我正在尝试自动在集群上部署应用程序。

This has nothing to do with the Jenkins CI pipeline or Kubernetes. 这与Jenkins CI管道或Kubernetes无关。 Jenkins will not be able to push your images until configure follow either of the below steps Jenkins将无法推送您的图像,直到按照以下任一步骤进行配置

You have two options here 您有两个选择

1) Configure your docker client to use the secure registry over HTTPS. 1)配置您的Docker客户端以通过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. 2)第二种解决方案是通过未加密的HTTP连接使用注册表。 So if you are running docker on kubernetes. 因此,如果您在kubernetes上运行docker。 You will have to configure the daemon.json file in /etc/docker/daemon.json . 您将必须在/etc/docker/daemon.json配置daemon.json文件。

PS: This file might not exist. PS:此文件可能不存在。 You will have to create it. 您将不得不创建它。

Then add in the below content. 然后添加以下内容。 Make sure you change the url to match your docker registry 确保您更改URL以匹配您的Docker注册表

{
  "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 然后使用systemctl restart dockeretc/init.d/docker restart具体取决于集群上安装的linux distro版本

Let me know if you have any questions 如果您有任何疑问,请告诉我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM