k8s基于Alpine镜像定制自己的镜像

alpine镜像只有5.6MB,而ubuntu镜像则近百MB,centos镜像近三百MB。

[root@master ~]# docker images
REPOSITORY     TAG         IMAGE ID            CREATED             SIZE
alpine         latest      a187dde48cd2        16 hours ago        5.6MB

默认官方源在国内很慢

# cat /etc/apk/repositories 
http://dl-cdn.alpinelinux.org/alpine/v3.11/main
http://dl-cdn.alpinelinux.org/alpine/v3.11/community

我们将其改为国内镜像源,将 dl-cdn.alpinelinux.org 改为 mirrors.aliyun.com 即可

# cat /etc/apk/repositories 
https://mirrors.aliyun.com/alpine/v3.11/main
https://mirrors.aliyun.com/alpine/v3.11/community
# apk update
# apk search curl     #查询
# apk add curl        #安装
# apk del curl        #卸载

基于Alpine定制带有curl的镜像

FROM alpine
RUN echo "https://mirrors.aliyun.com/alpine/v3.6/main/" > /etc/apk/repositories; \
    echo "https://mirrors.aliyun.com/alpine/v3.6/community/" >> /etc/apk/repositories; \
    apk add curl
# 默认是没有开启缓存的,所以装完也不用清缓存

构建出来的镜像也只有10.1MB

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
alpine-curl         latest              445635769f45        18 minutes ago      10.1MB
alpine              latest              a187dde48cd2        17 hours ago        5.6MB

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值