0
点赞
收藏
分享

微信扫一扫

@使用阿里云镜像仓库构建海外docker镜像及github code编写


文章目录

  • ​​一、构建海外镜像​​
  • ​​1、构建概述​​
  • ​​2、所需的平台​​
  • ​​3、实现的原理​​
  • ​​4、使用的步骤​​
  • ​​5、构建成功​​
  • ​​二、使用github编写代码文件​​
  • ​​1、github上申请账号​​
  • ​​2、创建一个新的资源库​​
  • ​​3、创建资源库目录​​
  • ​​4、复制文件地址(在本机上使用地址进行下载使用)​​
  • ​​5、本地测试使用​​

一、构建海外镜像

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文件的仓库

@使用阿里云镜像仓库构建海外docker镜像及github code编写_aliyun

2》 创建kube-apiserver镜像的Dockerfile

@使用阿里云镜像仓库构建海外docker镜像及github code编写_git_02

3》编写镜像代码地址及Dockerfile文件目录名称(阿里云添加地址必须与当前github目录名称一致)

@使用阿里云镜像仓库构建海外docker镜像及github code编写_github_03

@使用阿里云镜像仓库构建海外docker镜像及github code编写_构建海外镜像_04

@使用阿里云镜像仓库构建海外docker镜像及github code编写_git_05

4》使用阿里云的容器镜像服务创建一个仓库

@使用阿里云镜像仓库构建海外docker镜像及github code编写_docker_06


@使用阿里云镜像仓库构建海外docker镜像及github code编写_docker_07


@使用阿里云镜像仓库构建海外docker镜像及github code编写_git_08


@使用阿里云镜像仓库构建海外docker镜像及github code编写_aliyun_09

@使用阿里云镜像仓库构建海外docker镜像及github code编写_构建海外镜像_10


@使用阿里云镜像仓库构建海外docker镜像及github code编写_github_11


@使用阿里云镜像仓库构建海外docker镜像及github code编写_aliyun_12

4》奈斯 (σ゚∀゚)σ…:*☆哎哟不错哦

@使用阿里云镜像仓库构建海外docker镜像及github code编写_构建海外镜像_13

5、构建成功

@使用阿里云镜像仓库构建海外docker镜像及github code编写_构建海外镜像_14

二、使用github编写代码文件

1、github上申请账号

​​【github官网】​​​​【windows版git下载】​​

2、创建一个新的资源库

@使用阿里云镜像仓库构建海外docker镜像及github code编写_构建海外镜像_15

3、创建资源库目录

@使用阿里云镜像仓库构建海外docker镜像及github code编写_aliyun_16


@使用阿里云镜像仓库构建海外docker镜像及github code编写_docker_17

4、复制文件地址(在本机上使用地址进行下载使用)

@使用阿里云镜像仓库构建海外docker镜像及github code编写_docker_18

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 83 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文件已经上传成功】好兄弟啊😎😎😎😎

@使用阿里云镜像仓库构建海外docker镜像及github code编写_aliyun_19


举报

相关推荐

0 条评论