kubernetes(k8s)第四部分之配置本地镜像仓库

1】获取registry镜像

在一台能上网并且安装docker的主机上通过pull获取registry镜像。

[root@random ~]# docker pull registry

2】获取pod-infrastructure镜像

该镜像是在node节点创建pod时必须要有的。通过search你可以看到很多包含该名称的镜像,我下载的是下图标记的镜像。

[root@random ~]# docker search pod-infrastructure

将镜像pull到本地。

[root@random ~]# docker  pull  tianyebj/pod-infrastructure

[root@random docker]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                      latest              d1fd7d86a825        4 months ago        33.26 MB
tianyebj/pod-infrastructure   latest              34d3450d733b        16 months ago       205 MB

3】将镜像保存为tar包并发送给master节点

[root@random ~]# docker save -o pod-infrastructure.tar tianyebj/pod-infrastructure

[root@random ~]# docker save -o registry.tar registry

[root@random ~]# ls

pod-infrastructure.tar  registry.tar

[root@random ~]# scp pod-infrastructure.tar registry.tar root@172.25.37.11:

4】在master节点将镜像load

[root@k8s-master ~]# docker load -i registry.tar

[root@k8s-master ~]# docker load -i pod-infrastructure.tar

[root@k8s-master ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                      latest              d1fd7d86a825        4 months ago        33.3 MB
tianyebj/pod-infrastructure   latest              34d3450d733b        16 months ago       205 MB

5】将pod-infrastructure镜像存入仓库,node节点拉取镜像

启动私有仓库:

[root@k8s-master ~]# docker run -d -p 5000:5000 --name=registry --restart=always --privileged=true  --log-driver=none -v /home/data/registrydata:/tmp/registry registry

其中,/home/data/registrydata是一个比较大的系统分区,今后镜像仓库中的全部数据都会保存在这个外挂目录下。

镜像重命名:

[root@k8s-master docker]# docker tag  tianyebj/pod-infrastructure  registry:5000/pod-infrastructure

镜像push到私有仓库:

[root@k8s-master docker]# docker  push  registry:5000/pod-infrastructure

Node节点拉取镜像:

[root@k8s-node1 docker]# docker  pull  registry:5000/pod-infrastructure

[root@k8s-node2 docker]# docker  pull  registry:5000/pod-infrastructure

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值