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