简体   繁体   English

用Docker运行Jenkins master和slave

[英]Run Jenkins master and slave with Docker

I want to setup Jenkins master on server A and slave on server B with use of Docker. 我想使用Docker在服务器A上设置Jenkins master,在服务器B上设置slave。

Both servers are virtual machines dedicated for Jenkins. 两台服务器都是专用于Jenkins的虚拟机。

Currently I have started Docker container on server A for master , based on the official Jenkins docker image. 目前我已经在服务器A为主服务器启动了Docker容器,基于官方的Jenkins docker镜像。 But what docker image should I use for Jenkins slave ? 但是我应该为詹金斯奴隶使用什么码头图像?

That actually depends on the environment and tools you need in your build environment. 这实际上取决于构建环境中所需的环境和工具。 For example, if you build a C project, you would need an image containing a C compiler and possibly make if you use Makefiles. 例如,如果您构建一个C项目,则需要一个包含C编译器的图像,如果您使用Makefile,则可能make If you build a Java project, you would need a JDK with a Java compiler and possibly Ant / Maven / Gradle if you use them as part of your build. 如果您构建一个Java项目,那么如果您将它们用作构建的一部分,则需要一个带有Java编译器的JDK以及可能需要Ant / Maven / Gradle的JDK。

You can use the evarga/jenkins-slave as a good starting point for your build slave. 您可以使用evarga / jenkins-slave作为构建从站的良好起点。

This image already contains JDK. 此图像已包含JDK。 If you simply need JDK and Maven on your build slave, you can build your Docker image with the following Dockerfile : 如果您只需要构建从属服务器上的JDK和Maven,则可以使用以下Dockerfile构建Docker镜像:

FROM evarga/jenkins-slave

run apt-get install maven

Using Docker images for build slaves is actually a good idea. 将Docker镜像用于构建从属实际上是一个好主意。 Some of the reasons appear at Templating Jenkins Build Environments with Docker Containers : 部分原因出现在使用Docker容器的Templating Jenkins构建环境中

Docker has established itself as a popular and convenient way to bootstrap isolated and reproducible environments, which enables Docker containers to be the most maintainable slave environments. Docker已经成为引导隔离和可重现环境的流行且便捷的方式,这使得Docker容器成为最易维护的从属环境。 Docker containers' tooling and other configurations can be version controlled in an environment definition called a Dockerfile, and Dockerfiles allows multiple identical containers can be created quickly using this definition or for more customized off-shoots to be created by using that Dockerfile's image as a base. Docker容器的工具和其他配置可以在名为Dockerfile的环境定义中进行版本控制,Dockerfiles允许使用此定义快速创建多个相同的容器,或者使用Dockerfile的图像作为基础创建更多自定义的off-shoots 。

I suggest you take trying to use dynamic|ephemeral docker nodes, instead of manually creating nodes and connecting to them via ssh. 我建议你尝试使用动态|短暂的docker节点,而不是手动创建节点并通过ssh连接到它们。 Take a look at https://engineering.riotgames.com/news/putting-jenkins-docker-container , it's very powerful and I think it's one of killer usecases for Docker. 看看https://engineering.riotgames.com/news/putting-jenkins-docker-container ,它非常强大,我认为它是Docker的杀手级用例之一。

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

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