简体   繁体   English

如何使用docker正确设置jenkins?

[英]How to properly set up jenkins with docker?

I'm new to Docker and am learning how to implement Docker with Jenkins. 我是Docker的新手,正在学习如何用Jenkins实现Docker。 I was able to succesfully bind a docker volume to my host machine directory with the following command 我可以使用以下命令成功将docker卷绑定到主机目录

docker run –name jenkinsci -p 8080:8080 -p 50000:50000 -v ~/Jenkins:/var/jenkins_home/ jenkins/jenkins:lts docker run –name jenkinsci -p 8080:8080 -p 50000:50000 -v〜/ Jenkins:/ var / jenkins_home / jenkins / jenkins:lts

Now that the basic Jenkins is set up and binded to my host, there are a few things I wasn't sure to handle. 既然已经设置了基本的Jenkins并将其绑定到我的主机,那么我不确定有几件事要处理。

(1) This is only accessible through localhost:8080. (1)仅可通过localhost:8080访问。 How do I make this accessible to other computers? 如何使其他计算机可以访问此内容? I've read that I can change the URL to my company's public IP address? 我已经读到可以将URL更改为公司的公共IP地址吗? Is this the right approach? 这是正确的方法吗?

(2) I want to automate the installation of select plugins and setting the paths in the Global Tools Configuration. (2)我想自动执行选择插件的安装并在“全局工具配置”中设置路径。 There were some tips on github https://github.com/jenkinsci/docker/blob/master/README.md but I wasn't clear on where this Dockerfile is placed. 在github https://github.com/jenkinsci/docker/blob/master/README.md上有一些技巧,但我不清楚这个Dockerfile的放置位置。 For example, if I wanted the plugins MSBuild and Green Balls to be installed, what would that look like? 例如,如果我要安装MSBuild和Green Balls插件,那会是什么样?

FROM jenkins/jenkins:lts
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt

Would I have to create a text file called plugins.txt where it contains a list of plugins I want downloaded? 我是否必须创建一个名为plugins.txt的文本文件,其中包含要下载的插件列表? Where will this Dockerfile be stored? 该Dockerfile将存储在哪里?

(3) I also want a Dockerfile that installs all the dependencies to run my .NET Windows project (nuget, msbuild, wix, nunit, etc). (3)我还希望安装所有依赖项的Dockerfile来运行.NET Windows项目(nuget,msbuild,wix,nunit等)。 I believe this Dockerfile will be placed in my git repository. 我相信这个Dockerfile将放置在我的git仓库中。

Basically, I'm getting overwhelmed with all this Docker information and am trying to piece together how Docker interacts with Jenkins. 基本上,我对所有这些Docker信息不知所措,并试图拼凑Docker如何与Jenkins进行交互。 I would appreciate any advice and guidance on these problems. 对于这些问题,我将不胜感激。

Its ok to get overwhelmed by docker+kubernetes. 被docker + kubernetes淹没是可以的。 Its a lot of information and whole overall shift how we have been handling applications/services. 这是我们处理应用程序/服务的方式提供的大量信息和整体变化。

  1. To make jenkins available on all interfaces, use following command. 要使jenkins在所有接口上都可用,请使用以下命令。
docker run –name jenkinsci -p "0.0.0.0:8080:8080" -p "0.0.0.0:50000:50000" -v ~/Jenkins:/var/jenkins_home/ jenkins/jenkins:lts
  1. Yes, you have to provide the plugins.txt file, and create a new jenkins image containing all the required plugins. 是的,您必须提供plugins.txt文件,并创建一个包含所有必需插件的新jenkins映像。 After that you can use this new image instead of jenkins/jenkins:lts. 之后,您可以使用此新图像代替jenkins / jenkins:lts。
  2. The new image, suited for your workload should contain all the dependencies required for your environment. 适用于您的工作负载的新映像应包含环境所需的所有依赖项。

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

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