简体   繁体   English

Jenkins docker 代理后面的容器拒绝下载插件证书错误

[英]Jenkins docker container behind proxy refuses to download plugins cert error

Problem:问题:

When deploying Jenkins, at the time of installing plugins, every single plugin fails to download with the following Java error:部署 Jenkins 时,在安装插件时,每个插件都无法下载,并出现以下 Java 错误:

Caused: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Troubleshooting:故障排除:

  • Deployed in an env not behind a proxy, this worked fine.部署在不在代理后面的环境中,效果很好。
  • Tried changing the docker image type (used "jenkins" and "jenkinsci" neither worked) Info found here .尝试更改 docker 图像类型(使用的“jenkins”和“jenkinsci”均无效)信息在这里找到。
  • Read though all of this post Nothing on there helped.阅读所有这篇文章,那里没有任何帮助。
  • It seems that jenkins is trying to pull the plugins from the URL but cant validate the certificate.似乎 jenkins 正在尝试从 URL 中提取插件,但无法验证证书。 I tried adding the curl option for "-k" but this did not help.我尝试为“-k”添加 curl 选项,但这没有帮助。 I also tried downloading with curl outside of the container to see what happened.我还尝试在容器外使用 curl 下载,看看发生了什么。 It seemed I needed to use "-kL curl --proxy our.proxy.com:1234" to actual pull the plugin url and have it work.看来我需要使用“-kL curl --proxy our.proxy.com:1234”来实际拉插件url并让它工作However when adding ENV CURL_OPTIONS -Lk --proxy our.proxy.com:1234 and spinning up the container, I still see the same error.但是,当添加ENV CURL_OPTIONS -Lk --proxy our.proxy.com:1234并启动容器时,我仍然看到相同的错误。
  • Read though this post as well about how URLs may need to be whitelisted, but I dont think this is our issue because A) I was able to pull from one mirror without having to have our proxy be adjusted B) the error says its a certification path problem.请阅读这篇文章,了解如何将 URL 列入白名单,但我认为这不是我们的问题,因为 A)我能够从一个镜像中提取而无需调整我们的代理 B)错误说它是一个认证路径问题。
  • Why can I get the plugin url via curl+proxy outside of the container, but when Java tries to do it I get certificate errors?为什么我可以通过容器外部的 curl+proxy 获取插件 url,但是当 Java 尝试这样做时,我得到证书错误? Its not clear to me from the docker log output the java command being used to pull the plugins so I am not sure what is going on.从 docker 日志 output 中我不清楚 java 命令用于拉取插件,所以我不确定发生了什么。
  • Is there an option to disable Cert validation from Java?是否有从 Java 禁用证书验证的选项? I just need this to work as a POC right now so I dont care about validation checks at the moment, I can implement later.我现在只需要它作为 POC 工作,所以我现在不关心验证检查,我可以稍后实现。 Also this is going through a proxy and I dont have access to the proxies CA trust or the certs.这也是通过代理,我无权访问代理 CA 信任或证书。 Just want to disable Any recommendations?只是想禁用任何建议?

Environment:环境:

  • Ubuntu Server 18.04 Ubuntu 服务器 18.04
  • Docker version: 20.10.10 Docker 版本:20.10.10
  • Docker compose version: 1.29.2 Docker 组成版本:1.29.2

Config files:配置文件:

  • Docker Compose File: Docker 编写文件:
version: '3.7'
services:
  jenkins:
    container_name: jenkins
    build:
      context: ./jenkins
      dockerfile: ./jenkins.Dockerfile
    ports:
      - 8080:8080
      - 50000:50000
    volumes:
      - jenkins-data:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      DOCKER_SOCKET: /var/run/docker.sock
      ALL_PROXY: "http://our.proxy.com:1234"
      JAVA_OPTS: "-Dhttp.proxyHost=our.proxy.com -Dhttp.proxyPort=1234 -Dhttps.proxyHost=our.proxy.com -Dhttps.proxyPort=1234"

    privileged: true

volumes:
    jenkins-data:
  • Docker File: Docker 文件:
FROM jenkins/jenkins:latest
USER root
ENV CURL_OPTIONS -k --proxy our.proxy.com:1234

If the runtime environment can't install plugins, then you can configure the plugins to be installed through a plugins.txt file in an environment that can access the update center.如果运行环境不能安装插件,那么可以在可以访问更新中心的环境中,通过plugins.txt文件配置要安装的插件。 Build the container image in an environment where the update center is available, then copy the image to the final destination.在更新中心可用的环境中构建容器镜像,然后将镜像复制到最终目的地。

One example is in https://github.com/MarkEWaite/docker-lfs/tree/lts-with-plugins where it stores the plugin binaries in the Git repository as large files and defines the precise plugin versions in the plugins.txt file.一个示例是在https://github.com/MarkEWaite/docker-lfs/tree/lts-with-plugins中,它将插件二进制文件存储在 Git 存储库中作为大文件,并在 plugins.txt 文件中定义精确的插件版本. The resulting container image includes the plugins so that access to the update center is not required.生成的容器映像包含插件,因此不需要访问更新中心。

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

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