编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

Docker中的Docker,在包含Jenkins Server的Docker中构建Docker代理:Docker in Docker, Building docker agents in a docker contained Jenkins Server

jamband 云计算 2022-5-10 14:50 13人围观

腾讯云服务器
Docker中的Docker,在包含Jenkins Server的Docker中构建Docker代理的处理方法

我目前正在使用Docker运行Jenkins.在尝试构建Docker应用程序时,我面临是否应该通过绑定/var/run/docker.sock文件或在我的Jenkins Docker中安装另一个Docker实例在Docker(Dind)中使用Docker的疑问.实际上,我以前曾看到过,不建议使用docker.sock以外的其他方式.

I am currently running a Jenkins with Docker. When trying to build docker apps, i am facing some doubt on if i should use Docker in Docker (Dind) by binding the /var/run/docker.sock file or by installing another instance of docker in my Jenkins Docker. I actually saw that previously, it was discouraged to use something else than the docker.sock.

除了不污染主机,我实际上不明白为什么我们应该使用主机上的docker守护进程以外的其他东西.

I don't actually understand why we should use something else than the docker daemon from the host apart from not polluting it.

来源: https://itnext.io/docker-in-docker-521958d34efd

问题解答

"docker容器中的詹金斯需要docker"的最佳解决方案是将您的主机添加为jenkins中的节点(从属).这将使每个构建步骤(实际上是所有步骤)都在您的主机中运行.我花了一个月的时间才能找到完美的安装程序.

Best solution for "jenkins in docker container needs docker" case is to add your host as a node(slave) in jenkins. This will make every build step (literally everything) run in your host machine. It took me a month to find perfect setup.

在jenkins容器中安装Docker套接字::您将失去上下文.您要在映像内复制的文件位于jenkins容器中的工作区中,而您的docker在主机上运行.COPY肯定会失败.

Mount docker socket in jenkins container: You will lose context. The files you want to COPY inside image is located inside workspace in jenkins container and your docker is running at host. COPY fails for sure.

在jenkins容器中安装docker客户端:您必须更改官方的jenkins映像.增加了复杂性.而且您也会失去上下文.

Install docker client in jenkins container: You have to alter official jenkins image. Adds complexity. And you will lose context too.

将主机添加为jenkins节点:完美.你有局面.请勿更改官方图片.

Add your host as jenkins node: Perfect. You have the contex. No altering the official image.

这篇关于Docker中的Docker,在包含Jenkins Server的Docker中构建Docker代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程技术网(www.editcode.net)!

腾讯云服务器 阿里云服务器
关注微信
^