gpt4 book ai didi

docker - 如何配置动态配置的 Docker 代理

转载 作者:行者123 更新时间:2023-12-02 19:28:47 25 4
gpt4 key购买 nike

我在 Windows 10 上安装了 Docker,并从 Docker Hub 中提取了 jenkins docker。接下来,我启动了我的 jenkins docker,

docker run --rm -u root -p 8080:8080 -v my_host_path:/var/jenkins_home jenkins

接下来,我使用 Manage Jenkins 和 Manage Plugins 安装 Docker 插件,然后进入配置页面并尝试添加 Docker Cloud。

我进入后 Docker 主机 URI :tcp://127.0.0.1:2375,我想 “测试连接” ,但不幸的是失败了。

我尝试按照以下链接的说明进行操作:
How to find "Docker Host URI" to be used in Jenkins "Docker Plugin"?

但是我在 jenkins 容器的/etc/default/* 下找不到任何 docker 设置文件,所以我无法设置 DOCKER_OPTS 争论。

有人可以给我任何建议吗?谢谢 !

最佳答案

问题背景:Rafal Leszko 的《使用 Docker 和 Jenkins 进行持续交付》一书第 3 章练习的结尾

来自 Configure and troubleshoot the Docker daemon page

Important: Setting hosts in the daemon.json is not supported on Docker Desktop for Windows or Docker Desktop for Mac.



设置 docker host uri不适用于 Windows。因此,这些中的任何一个都不会在“设置”>“守护程序”选项卡中工作:
  • “主机”:“-H tcp://0.0.0.0:2375”
  • “DOCKER_OPTS”:“-H tcp://0.0.0.0:2375”

  • 按照某些地方的建议,在没有 TLS(常规选项卡上的复选框)的情况下公开守护程序对我也不起作用。

    将 Jenkins 中的 Docker 插件与 docker 主机连接的解决方案是:
    使用特殊的 DNS 名称 host.docker.internal

    来自 docs :

    How do I connect from a container to a service on the host? Windows has a changing IP address (or none if you have no network access). We recommend that you connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purposes and will not work in a production environment outside of Docker Desktop for Windows. The gateway is also reachable as gateway.docker.internal. For more information about the networking features in Docker Desktop for Windows, see Networking.



    虽然“不会在 Docker Desktop for Windows 之外的生产环境中工作”的免责声明可能会打扰一些人,但我相信 Docker for Windows 无论如何都不适合生产用例。

    此外,为 Jenkins 代理-主通信 -p 50000:50000 发布此映射

    关于docker - 如何配置动态配置的 Docker 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53698464/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com