《OpenShift 4.x HOL教程汇总》

通过oc命令复制镜像

Openshift的客户端工具oc命令提供了镜像mirror功能,可用来在2个Container Registry之间复制镜像。

说明:以下操作需要有2个Container Registry环境。本示例将hello-openshift镜像从“registry.domain.com”节点复制到“registry.example.internal”节点的Container Registry上。复制操作在“registry.domain.com”节点上进行,验证操作在“registry.example.internal”节点上进行。

  1. 在“registry.domain.com”节点上设置环境变量
$ SOURCE=registry.domain.com
$ TARGET=registry.example.internal
  1. 将访问“registry.example.internal”节点的Container Registry用到的公钥证书文件(例如support.crt)复制到“registry.domain.com”。
$ scp root@${TARGET}:/etc/pki/ca-trust/source/anchors/support.crt /etc/pki/ca-trust/source/anchors/
$ update-ca-trust
  1. 验证在“registry.domain.com”节点上可以同时访问2个Container Registry,且2个Registry中都没有hello-openshift镜像。
$ docker login ${SOURCE}:5000 -u user1 -p password1
Login Succeeded
$ docker login ${TARGET}:5000 -u openshift -p redhat
Login Succeeded
$ curl -u user1:password1 https://${SOURCE}:5000/v2/_catalog
{"repositories":["busybox"]}
curl -u openshift:redhat https://${TARGET}:5000/v2/_catalog
{"repositories":[]}
  1. pull/push 镜像到“registry.domain.com”节点的Registry。
$ docker pull openshift/hello-openshift
Using default tag: latest
Trying to pull repository docker.io/openshift/hello-openshift ...
latest: Pulling from docker.io/openshift/hello-openshift
4f4fb700ef54: Pull complete
8b32988996c5: Pull complete
Digest: sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e
Status: Downloaded newer image for docker.io/openshift/hello-openshift:latest$ docker tag docker.io/openshift/hello-openshift ${SOURCE}:5000/openshift/hello-openshift$ docker push ${SOURCE}:5000/openshift/hello-openshift
The push refers to a repository [registry.domain.com:5000/openshift/hello-openshift]
da0e4d9121c7: Pushed
5f70bf18a086: Pushed
latest: digest: sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e size: 734
  1. 复制hello-openshift镜像。
$ oc image mirror ${SOURCE}:5000/openshift/hello-openshift ${TARGET}:5000/openshift/hello-openshift
registry.example.internal:5000/openshift/hello-openshiftblobs:registry.domain.com:5000/openshift/hello-openshift sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1 32Bregistry.domain.com:5000/openshift/hello-openshift sha256:7af3297a3fb4487b740ed6798163f618e6eddea1ee5fa0ba340329fcae31c8f6 1.336KiBregistry.domain.com:5000/openshift/hello-openshift sha256:8b32988996c5d776076ea3cd672855f6d0faac87510064a15cce4bd02cdc9d13 2.067MiBmanifests:sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e -> lateststats: shared=0 unique=3 size=2.068MiB ratio=1.00phase 0:registry.example.internal:5000 openshift/hello-openshift blobs=3 mounts=0 manifests=1 shared=0info: Planning completed in 40ms
uploading: registry.example.internal:5000/openshift4/hello-openshift sha256:8b32988996c5d776076ea3cd672855f6d0faac87510064a15cce4bd02cdc9d13 2.067MiB
sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e registry.example.internal:5000/openshift4/hello-openshift:latest
info: Mirroring completed in 390ms (5.426MB/s)
  1. 在目标“registry.example.internal”上运行hello-openshift镜像,确认容器启动成功。
$ curl -u openshift:redhat https://registry.example.internal:5000/v2/_catalog
{"repositories":["openshift/hello-openshift"}
$ docker run -it registry.example.internal:5000/openshift/hello-openshift
Unable to find image 'registry.example.internal:5000/openshift/hello-openshift:latest' locally
Trying to pull repository registry.example.internal:5000/openshift/hello-openshift ...
latest: Pulling from registry.example.internal:5000/openshift/hello-openshift
4f4fb700ef54: Pull complete
8b32988996c5: Pull complete
Digest: sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e
Status: Downloaded newer image for registry.example.internal:5000/openshift/hello-openshift:latest
serving on 8888
serving on 8080

通过skopeo命令复制镜像

所需环境同上一节。执行以下命令,在目标“registry.example.internal”节点上用skopeo命令复制“registry.domain.com”节点的openshift/hello-openshift镜像,并改名为“openshift/my-hello-openshift”。

$ skopeo copy docker://${SOURCE}:5000/openshift/hello-openshift docker://${TARGET}:5000/openshift/my-hello-openshift --src-creds=user1:password1 --dest-creds=openshift:redhat
Getting image source signatures
Copying blob 8b32988996c5 done
Copying blob 4f4fb700ef54 done
Copying config 7af3297a3f done
Writing manifest to image destination
Storing signatures$ curl -u openshift:redhat https://${TARGET}:5000/v2/_catalog
{"repositories":["openshift/my-hello-openshift"}

容器入门(5)- 在Registry之间复制镜像相关推荐

  1. 容器入门(4) - skopeo

    <OpenShift 4.x HOL教程汇总> 文章目录 对独立的Docker Registry操作 查看Registry上的Image信息 在2个Registry之间复制Image 对O ...

  2. OpenShift 4 - 部署Mirror Registry并复制Image

    <OpenShift 4.x HOL教程汇总> 文章目录 安装Mirror Registry运行环境 复制Image到Mirror Registry 准备登陆认证文件 生成远程Regist ...

  3. 容器入门(8) - 镜像签名

    <OpenShift 4.x HOL教程汇总> 说明 本文将对测试镜像签名,然后推送到本地Docker Registry上.当用户有签名对应秘钥时,可以正常从Docker Registry ...

  4. 容器入门(6) - 获取访问Docker Registry的公钥证书

    <OpenShift 4.x HOL教程汇总> 获取问Docker Registry的证书 在根据<容器入门(1) - 安装和使用Docker Registry>,我们可以使用 ...

  5. 容器入门(1) - 安装和使用Docker Registry

    <OpenShift 4.x HOL教程汇总> 文章目录 部署拓扑 准备宿主机 创建SSL证书和用户认证文件 安装Docker环境 打开防火墙 安装Docker Registry 基于容器 ...

  6. 查看容器ID以及如何在docker和宿主机之间复制文件

    docker ps -a  查看正在运行的容器 docker ps -a | grep [容器名]  根据容器名查询容器ID 进入容器:docker exec -it  [容器ID]  /bin/sh ...

  7. Docker容器入门及网易最佳实践

    文章目录 第一节 Docker容器入门 1.1.1 基础概念 1. Docker是什么 2. Docker和传统虚拟机的对比 3. 为什么要使用Docker 4. Docker架构 5. Docker ...

  8. 理论+实操:docker入门初体验,申请阿里镜像加速器

    文章目录 一:Docker概述 1.1 docker概念: 1.2 docker设计的目标: 1.3 docker的组成: 1.4 docker的使用场景 1.5 docker版本: 二: docke ...

  9. Registry和Harbor镜像仓库实例

    Docker Registry介绍 网上有很多的Registry服务器都支持第三方用户注册,而后基于用户名去做自己的仓库,但是使用互联网上的Registry有一个缺陷,那就是我们去推送和下载镜像时都不 ...

最新文章

  1. jQuery ajax的traditional参数的作用
  2. ES6一些新特性记录
  3. phpmyadmin配置
  4. idea IDE 常用快捷键记录
  5. 【操作系统/OS笔记11】并发执行的必要性,产生的问题,原子操作,为什么引入锁机制,面包购买的类比
  6. ios uiview动画_iOS UIView动画
  7. pci转并口卡的安装使用
  8. python研究生录取数据分析统计服_考研党必看!研究生报考录取比例数据查询方法...
  9. MOSFet cutoff frequency ( From google)
  10. 爬虫demo——爬取电影天堂的资源,存储到本地json文件
  11. Vue获取当前的位置信息、经纬度
  12. Kodu的下载与安装---Kodu少儿编程第二天
  13. JavaPoet使用攻略
  14. 【网络工程师配置篇】——OSPF基础配置!
  15. 50个Java精品源码免积分下载
  16. 试述现代计算机系统的多级层次结构,计算机系统结构测验题(一)答案.ppt
  17. 生化危机8吸血鬼夫人暴君皮肤MOD
  18. Internet Download Manager6.40最高版电脑高速下载工具
  19. 《使用QSortFilterProxyModel实现QTreeView行列过滤》:系列教程之十
  20. 遭遇难缠的病毒群ntldr.exe和c0nime.exe等,可杀

热门文章

  1. scp传服务器文件,使用tar、scp和screen在服务器之间传输文件
  2. 无法读取内存属于错误吗_索佳全站仪错误信息讲解
  3. mysql like in 数组_Web前端学习教程之常用的MySQL优化技巧
  4. 祥云,灯笼,剪纸……春节海报,点缀必备PSD素材
  5. 电商无线端秋季促销PSD分层海报,大战之前设计师准备好了么?
  6. UI超实用通用图标素材模板
  7. 电阻参数_贴片电阻的参数标识与贴片电阻的选择
  8. MyBatis的概述及使用
  9. Linux/Document: Livepatch
  10. [译转] eBPF 概念和基本原理