Jenkins-slave 镜像集成 docker 和 kubectl

本文介绍如何通过修改 Jenkins jnlp-slave 镜像,集成 Docker 和 Kubectl 命令,以实现更强大的 CI/CD 功能。通过更改下载源,安装 Docker-ce 并下载 Kubectl 文件,构建新的镜像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

转载于:https://www.cnblogs.com/weavepub/p/11388270.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值