containerd环境下build镜像

安装container和nerdctl和buildkit

https://blog.csdn.net/omaidb/article/details/128677718

buildkit项目地址:https://github.com/moby/buildkit
nerdctl 也可以和 buildkit 结合使用来构建容器镜像。


使用nerdctl构建docker镜像

参考:
https://developer.aliyun.com/article/1094835
https://mp.weixin.qq.com/s/Bjn0s5qRh2H9I__mAYh4jg


修改Dockerfile

https://blog.csdn.net/omaidb/article/details/121434775


构建镜像

# 构建镜像
./Dockerfile |nerdctl build -t 镜像名:tag

# 构建镜像
nerdctl build -t 镜像名:tag .

# 查看构建好的镜像
nerdctl images

containerd配置代理

老是替换源太麻烦了,直接上代理
https://segmentfault.com/a/1190000020363043

# 创建/etc/systemd/system/containerd.service.d目录
mkdir /etc/systemd/system/containerd.service.d

# 配置代理
cat > /etc/systemd/system/containerd.service.d/proxy.conf << EOF
> [Service] 
> Environment="HTTP_PROXY=socks5://127.0.0.1:1080" 
> Environment="HTTPS_PROXY=socks5://127.0.0.1:1080"  "NO_PROXY=localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,docker-registry.somecorporation.com,isdp30x2.mirror.aliyuncs.com,hub-mirror.c.163.com,mirror.baidubce.com"'
> EOF

# 重启containerd服务
systemctl daemon-reload
systemctl restart containerd

# 查看配置的代理
systemctl show --property=Environment containerd.service 

containerd配置代理ansible剧本

---
- hosts: all
  tasks:
    - name: 创建containerd.service.d目录
      file:
        path: /etc/systemd/system/containerd.service.d
        state: directory

    - name: 创建proxy.conf文件
      file:
        path: /etc/systemd/system/containerd.service.d/proxy.conf
        state: touch

    - name: 为http_proxy.conf文件添加配置信息
      copy:
        content: |
          [Service]
          Environment="HTTP_PROXY=socks5://127.0.0.1:1080" 
          Environment="HTTPS_PROXY=socks5://127.0.0.1:1080"  "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com,isdp30x2.mirror.aliyuncs.com,hub-mirror.c.163.com,mirror.baidubce.com"
        dest: /etc/systemd/system/containerd.service.d/proxy.conf
      notify: 重启containerd服务

  handlers:
    - name: 重启containerd服务
      systemd:
        state: restarted
        daemon_reload: yes
        name: containerd
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

识途老码

赞赏是第一生产力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值