@使用阿里云镜像仓库构建海外docker镜像及github code编写
文章目录
一、构建海外镜像
1、构建概述
1》使用docker或者kuberneres的用户可能知道,有时候我们在下载一些镜像的时候却因为是海外的镜像导致下载失败,使用合法的FQ却又成本太高
2》有一个简单而又实用的海外镜像构建方法(如果所需要的镜像版本不是特别高可以在国内的一些仓库中找到,如果需要的镜像版本特别高,而且是最近更新的,那么就需要自己去获取国外的镜像)
2、所需的平台
1)github 平台
2)阿里云平台
3、实现的原理
1》首先利用Dockerfile定义需要构建的镜像
2》利用阿里云容器镜像服务的海外镜像构建功能去下载海外镜像到阿里云国内的仓库
3》使用docker pull下载阿里云构建完成的镜像,将镜像pull到本地,之后对镜像重新打标签改名,就可以将海外所需要的镜像下载到本地了
4、使用的步骤
案列:【构建k8s.gcr.io/kube-apiserver:v1.14.1】
1》登录github平台,创建一个存储自己Dockerfile文件的仓库
2》 创建kube-apiserver镜像的Dockerfile
3》编写镜像代码地址及Dockerfile文件目录名称(阿里云添加地址必须与当前github目录名称一致)
4》使用阿里云的容器镜像服务创建一个仓库
4》奈斯 (σ゚∀゚)σ…:*☆哎哟不错哦
5、构建成功
二、使用github编写代码文件
1、github上申请账号
2、创建一个新的资源库
3、创建资源库目录
4、复制文件地址(在本机上使用地址进行下载使用)
5、本地测试使用
首先本地安装使用的软件包 git
1》#使用yum安装Git软件包
[root@hzl ~]# yum install git -y
2》#使用复制的Github地址进行克隆创建好的目录
[root@hzl ~]# git clone https://github.com/hzl888/kubernetes-dashboard.git #使用的github目录
git clone https://github.com/hzl888/kubernetes-dashboard.git
正克隆到 'kubernetes-dashboard'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
[root@hzl ~]# ll
总用量 0
drwxr-xr-x 3 root root 51 8月 3 10:50 kubernetes-dashboard #使用克隆生成的文件
3》#创建子目录(可以跳过,不用执行)
[root@hzl ~]# cd kubernetes-dashboard #切换到克隆的目录
[root@hzl kubernetes-dashboard]# git add . #创建子目录
4》#上创文件,必须标记文件,对文件进行 tag
(用户及邮箱可以随便定义,但不可跳过,为了你能继续使用,只能指定才能使用)
[root@hzl kubernetes-dashboard]# git commit
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'root@nod02.(none)')
5》#设定用户(必须执行)
[root@hzl kubernetes-dashboard]# git config --global user.name "hzl888"
[root@hzl kubernetes-dashboard]# git config --global user.email "2014432134@qq.com"
6》#本地code传输
[root@hzl kubernetes-dashboard]# git push -u origin master #本地code上传
Username for 'https://github.com': hzl888
Password for 'https://hzl888@github.com':
分支 master 设置为跟踪来自 origin 的远程分支 master。
Everything up-to-date
7》#检查上传的code
【查看code文件已经上传成功】好兄弟啊😎😎😎😎
本文来自博客园,作者:ଲ一笑奈&何,转载请注明原文链接:https://www.cnblogs.com/zeny/p/15121469.html