最近在学习Kubernetes,需要在本地搭建一个Kubernetes的集群,但是发现获取安装包比较头疼,因为Kubernetes的镜像都放在gcr.io上,同时因为我们那伟大的墙的存在,在国内是不能访问的。当然,在国内是可以使用其他地方的镜像的,例如阿里的,但是版本的更新没那么快,在这里,介绍另外一种获取官方镜像的方式。
准备工作
- 准备GitHub账号,用于创建docker file;
- 准备Docker Hub账号,用于根据docker file构建docker镜像。
原理介绍
Docker Hub是一个镜像仓库,在国内也能访问,但是它的服务器是在国外,它的服务器能访问国内被墙的资源,在GitHub创建一个docker file,然后通过docker hub的构建镜像功能找到镜像资源并构建出docker镜像,最后通过docker hub拿镜像到国内。
获取步骤
- 首先登录GitHub,创建一个项目

然后创建一个Dockerfile文件,文件内容如下:
FROM gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0
MAINTAINER leo.lee <lis85@163.com>

- 在Docker Hub上构建Docker镜像
登录Docker Hub,选择【Create
】-【Create Automated Build】

- 绑定GitHub账号


- 构建Docker镜像



构建镜像,这里的【Docker Tag Name】要写清楚,不然在到仓库里面就看不明白了。


- 拉取镜像到本地

docker pull leolee32/kubernetes-library
网友评论