如何配置动态配置的Docker代理 [英] How to configure dynamically provisioned Docker agents

查看:90
本文介绍了如何配置动态配置的Docker代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 10上安装了Docker,并从Docker Hub中拉了jenkins docker。接下来,我启动了我的詹金斯码头工人,

I installed Docker on Windows 10, and I pulled jenkins docker from Docker Hub. Next, I started my jenkins docker,

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

接下来,我使用Manage Jenkins和Manage Plugins安装Docker插件,然后转到

Next, I used Manage Jenkins and Manage Plugins to install Docker plugin, then went to the Configure page and tried to add Docker Cloud.

输入 Docker Host URI 后:tcp://127.0.0.1:2375,我想要测试连接 ,但很不幸失败。

After I entered Docker Host URI : tcp://127.0.0.1:2375, I wanted to "Test Connection", but unfortunately got failed.

我尝试按照以下链接进行操作:
如何查找 Docker Host URI ;可以在Jenkins的 Docker插件中使用?

I tried to follow the instruction as below link: How to find "Docker Host URI" to be used in Jenkins "Docker Plugin"?

但是我在/ etc / default / *下找不到任何docker设置文件jenkins容器,所以我不能设置 DOCKER_OPTS 参数。

But I can't not find any docker setting file under /etc/default/* in my jenkins container, so I can't set the DOCKER_OPTS argument.

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

Could someone give me any advise? Thank you !

推荐答案

问题上下文:Rafal Leszko的使用Docker和Jenkins进行连续交付一书的第3章练习结束

Problem context: end of Chapter 3 exercise from the book "Continuous Delivery with Docker and Jenkins" by Rafal Leszko

来自配置Docker守护程序页面并进行故障排除


重要提示:Windows的Docker桌面或Mac的Docker桌面不支持在daemon.json中设置主机。 / p>

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

设置 docker主机uri 在Windows上不起作用。因此,这些设置均不能在设置>守护程序选项卡中使用:

Setting the docker host uri does NOT work on Windows. So either of these won't work in the Settings > Daemon tab:


  1. 主机:-H tcp://0.0。 0.0:2375

  2. DOCKER_OPTS: -H tcp://0.0.0.0:2375

在某些地方建议按揭露不带TLS的守护进程(常规选项卡上的复选框)对我也不起作用。

Exposing the daemon without TLS (checkbox on General tab) as recommended in some places did not work for me either.

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

The solution to connecting the Docker plugin in Jenkins with the docker host, is: use the special DNS name host.docker.internal

来自 docs


如何从容器连接到主机上的服务?
Windows的IP地址正在更改(如果没有网络访问权限,则没有IP地址)。我们建议您连接到特殊的DNS名称host.docker.internal,它将解析为主机使用的内部IP地址。这是出于开发目的,不适用于Docker Desktop for Windows以外的生产环境。
网关也可以通过gateway.docker.internal访问。
有关Windows Docker桌面中网络功能的更多信息,请参见网络。

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.

虽然'在Windows的Docker桌面免责声明之外的生产环境可能会打扰一些人,我相信Windows的Docker仍然不是用于生产用例。

While the 'will not work in a production environment outside of Docker Desktop for Windows' disclaimer might bother some, I believe Docker for Windows is not meant for production use cases anyway.

此外,针对以下情况发布此映射Jenkins代理人-主沟通-p 50000:50000

Additionally, publish this mapping for Jenkins agent-master communication -p 50000:50000

这篇关于如何配置动态配置的Docker代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆