Jenkins的Dockerfile

我在Docker和Jenkins中是全新的,我想试着问你,也许你能帮助我。

我想创build一个所有必要的Jenkins部件的Dockerfile,以便能够创build一个自动化的任务来检出github。

所以首先我在github上find了公共dockerfile( https://github.com/jenkinsci/docker/blob/master/Dockerfile ),但是它包含了很多参数,我不确定是否必须使用整个Dockerfile。

首先,你可以给我一个build议,如何修改dockerfile? 或者build议使用原始的Dockerfile(URL是上面的)?

谢谢你的build议,伙计们,祝你有美好的一天。

根本不要修改Dockerfile。 创build一个新的 Dockerfile,以下面的开头:

FROM jenkins 

然后将您的更改放在下面。 这将包括官方Jenkins图片中的所有内容,然后添加您的自定义项。

docs.docker.com上有一些相当不错的文档,特别是关于编写Dockerfiles的最佳实践。

使用任何这些 Docker images作为Dockerfile基础镜像并创build。

标准的过程是延伸上游的图像。 唯一需要从上游项目中提取Dockerfile并直接修改它的方法是,如果你的公司策略要求你从头开始构build所有的东西,或者上游的Dockerfile做了一些不正确的扩展(例如定义Dockerfile中的卷)。 扩展的原因是,您可以轻松获取最新的修补程序,方法是拉动上游映像并重build您的子映像,而不尝试将更改重新应用到Dockerfile。

Docker中心的“官方”jenkins图像已经移动了几次。 它曾经是jenkins/jenkins,然后作为jenkins进入官方图书馆:最新的,现在它被移到jenkins/jenkins: 如何扩展上游图像的例子如下例所示:

 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"] 

我已经在我的github回购了这个例子的其余部分: https : //github.com/bmitch3020/jenkins-docker