简体   繁体   English

詹金斯的Dockerfile

[英]Dockerfile for Jenkins

I'm absolutely new in Docker and Jenkins and I want to try to ask you, maybe you are able to help me. 我绝对不是Docker和Jenkins的新手,我想尝试问你,也许您可​​以帮助我。

I want to create a Dockerfile with all necessarily Jenkins parts to be able to create an automated task for checking out a github. 我想创建一个包含所有必不可少的Jenkins部分的Dockerfile,以便能够创建用于签出github的自动化任务。

So firstly I found the public dockerfile on github ( https://github.com/jenkinsci/docker/blob/master/Dockerfile ), but it includes a lot of parameters and I'm not sure, if is necessarily to use the whole Dockerfile. 所以首先我在github( https://github.com/jenkinsci/docker/blob/master/Dockerfile )上找到了公共dockerfile,但是它包含很多参数,我不确定是否一定要使用整个Dockerfile。

Firstly, can you just give me an advice, how to modify the dockerfile? 首先,您能给我一个建议,如何修改dockerfile吗? Or is recommended to use the original Dockerfile (URL is upper)? 还是建议使用原始的Dockerfile(URL在上)?

Thank you for any advice, guys, have a nice day. 谢谢大家的建议,祝大家有美好的一天。

Don't modify the Dockerfile at all . 不要修改Dockerfile 可言 Create a new Dockerfile that starts with: 创建一个新的 Dockerfile,其开头为:

FROM jenkins

And then place your changes below that. 然后将您的更改放在下面。 This will include everything in the official Jenkins image, and then add your customizations. 这将包括官方Jenkins图像中的所有内容,然后添加您的自定义项。

There are some pretty good docs on docs.docker.com , in particular this one talks about best practices for writing Dockerfiles. docs.docker.com上有一些非常不错的文档,特别是这篇 文章 ,讨论了编写Dockerfile的最佳实践。

这些 Docker images任何一个用作Dockerfile基础映像并创建。

The standard process is to extend upstream images. 标准过程是扩展上游图像。 The only need to pull the Dockerfile from an upstream project and modify it directly is if you have a company policy that requires you to build everything from scratch, or upstream is doing something incorrect with their Dockerfile that you cannot correct by extending it (eg defining volumes in the Dockerfile). 唯一需要从上游项目中提取Dockerfile并直接对其进行修改的情况是,如果您有一项公司政策要求您从头开始构建一切,或者上游公司对其Dockerfile做了不正确的事情,而您无法通过扩展对其进行纠正(例如,定义Dockerfile中的卷)。 The reason for extending is that you can easily get the latest patches by pulling the upstream image and rebuilding your child images without trying to reapply their changes to your Dockerfile. 扩展的原因是,您可以通过拉起上游映像并重建子映像轻松获得最新的补丁程序,而无需尝试将其更改重新应用于Dockerfile。

The "official" jenkins image on the Docker hub has moved around a few times. Docker中心上的“官方”詹金斯映像已经移动了几次。 It used to be jenkinsci/jenkins, then it moved into the official library as jenkins:latest, and now it's moved to jenkins/jenkins:lts. 它以前是jenkinsci / jenkins,然后以jenkins:latest的形式移入官方库,现在移至jenkins / jenkins:lts。 An example of how you'd extend the upstream image looks like the below example: 下面的示例显示了如何扩展上游图像的示例:

FROM jenkins/jenkins:lts

ARG GOSU_VERSION=1.10

# switch to root, let the entrypoint drop back to jenkins
USER root

# install debian packages, gosu, and docker
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
     vim \
     wget \
 && dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
 && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
 && chmod +x /usr/local/bin/gosu \
 && gosu nobody true \
 && curl -sSL https://get.docker.com/ | sh \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

# entrypoint is used to update docker gid and revert back to jenkins user
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

I've got the rest of this example in my github repo: https://github.com/bmitch3020/jenkins-docker 我已经在github存储库中获得了本示例的其余部分: https : //github.com/bmitch3020/jenkins-docker

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

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