Jenkins-slave 镜像集成 docker 和 kubectl

北城以北 提交于 2020-11-06 08:55:20

1、说明

对官方的 jenkins/jnlp-slave 镜像集成 docker 和 kubectl 命令。

 

2、Dockerfile 文件

该镜像底层采用的是 Debian 系统,先更改下载源,然后安装 docker-ce,并下载 kubectl 文件(因官网下载链接有墙,故用 rancher 提供的下载链接)。

FROM jenkins/jnlp-slave
ENV KUBECTL_VERSION=v1.14.5
USER root
RUN echo "deb http://mirrors.163.com/debian/ stretch main" > /etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list
RUN apt-get update && \
    apt-get -y install apt-transport-https ca-certificates curl software-properties-common && \
    curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/debian/gpg | apt-key add - && \
    add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable" && \
    apt-get -y update && \
    apt-get -y install docker-ce
RUN curl -L https://www.cnrancher.com/download/kubernetes/linux-amd64-${KUBECTL_VERSION}-kubectl -o /usr/local/bin/kubectl \
    && chmod +x /usr/local/bin/kubectl

构建镜像

docker build -t jenkins-jnlp-slave-docker-kubectl .

 

 

参考:https://hub.docker.com/r/nipsuli/docker-jnlp-slave-kubectl/dockerfile

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!