共有镜像docker hub

  1. 首先得在 Docker Hub 上注册一个账号。
  2. 在 Docker Host 上登录。
root@ubuntu:/home/yj# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: laster0xox0
Password:
Login Succeeded
  1. 修改镜像的 repository 使之与 Docker Hub 账号匹配。
    Docker Hub 为了区分不同用户的同名镜像,镜像的 registry 中要包含用户名,完整格式为:[username]/image:tag
root@ubuntu:/home/yj# docker tag httpd laster0xox0/httpd:v1
root@ubuntu:/home/yj# docker images laster0xox0/httpd
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
laster0xox0/httpd   v1                  0240c8f5816c        10 days ago         132MB
  1. 通过 docker push 将镜像上传到 Docker Hub。 Docker 会上传镜像的每一层。
root@ubuntu:/home/yj# docker push laster0xox0/httpd:v1
The push refers to repository [docker.io/laster0xox0/httpd]
7857c7afb135: Mounted from library/httpd
0ace1cc25781: Mounted from library/httpd
355bd981febe: Mounted from library/httpd
504b6a6a6fd2: Mounted from library/httpd
237472299760: Mounted from library/httpd
v1: digest: sha256:a1ae45c9153b02ccf2d790882a7aa833fcef8cc1fa5fd3cc3990c2e41fb47c6c size: 1367
  1. 登录 https://hub.docker.com,在Public Repository 中就可以看到上传的镜像。如果要删除上传的镜像,只能在 Docker Hub 界面上操作。

  2. 这个镜像可被其他 Docker host 下载使用了。

root@ubuntu:/home/yj# docker pull laster0xox0/httpd:v1
v1: Pulling from laster0xox0/httpd
Digest: sha256:a1ae45c9153b02ccf2d790882a7aa833fcef8cc1fa5fd3cc3990c2e41fb47c6c
Status: Image is up to date for laster0xox0/httpd:v1

本地仓库Registry

  1. 启动 registry 容器。
root@ubuntu:/home/yj# docker run -d -p 5000:5000 -v /myregistry:/var/lib/registry registry:2
Unable to find image 'registry:2' locally
2: Pulling from library/registry
d6a5679aa3cf: Pull complete
ad0eac849f8f: Pull complete
2261ba058a15: Pull complete
f296fda86f10: Pull complete
bcd4a541795b: Pull complete
Digest: sha256:5a156ff125e5a12ac7fdec2b90b7e2ae5120fa249cf62248337b6d04abc574c8
Status: Downloaded newer image for registry:2
0e9835e9c0cebbe31aeabc076c1df8a24a7fa2435266882da5db6ac440d27899
  1. 通过 docker tag 重命名镜像,使之与 registry 匹配。
root@ubuntu:/home/yj# docker tag laster0xox0/httpd:v1 127.0.0.1:5000/laster0xox0/httpd:v1

repository 的完整格式为:[registry-host]:[port]/[username]/xxx

  1. 通过 docker push 上传镜像。
root@ubuntu:/home/yj# docker push 127.0.0.1:5000/laster0xox0/httpd:v1
The push refers to repository [127.0.0.1:5000/laster0xox0/httpd]
7857c7afb135: Pushed
0ace1cc25781: Pushed
355bd981febe: Pushed
504b6a6a6fd2: Pushed
237472299760: Pushed
  1. 查看本地镜像
root@ubuntu:/myregistry/docker/registry/v2/repositories# docker search 127.0.0.1:5000/laster0xox0
Error response from daemon: Unexpected status code 404
root@ubuntu:/myregistry/docker/registry/v2/repositories# curl http://127.0.0.1:5000/v2/_catalog
{"repositories":["laster0xox0/httpd"]}
  1. 现在已经可通过 docker pull 从本地 registry 下载镜像了。

容器学习 之 本地镜像与共有镜像(十)相关推荐

  1. 容器学习 之 镜像命令(九)

    images 显示镜像列表 root@ubuntu:/home/yj# docker images REPOSITORY TAG IMAGE ID CREATED SIZE my-image late ...

  2. 容器学习Day09-理解容器镜像

    目录 前言 一.理解容器镜像 1.什么是容器镜像? 2.容器镜像结构 3.容器镜像技术实现 二.镜像仓库 1.Repository 2.Registry 三.镜像的拉取和删除 1.查找镜像 2.拉取镜 ...

  3. docker学习(三):docker镜像分层原理及本地镜像推送到阿里云或私服

    文章目录 前言 docker镜像分层加载原理 docker镜像commit操作产生新镜像 本地镜像发布到阿里云 将本地镜像推送到私有库 前言 大家好,这是我学习docker系列的笔记文章,目标是掌握d ...

  4. Docker学习之二------基础命令(镜像、容器)

    Docker基础命令 配置文件路径: /etc/sysconfig/docker docker镜像及容器目录 docker主目录:/var/lib/docker 存放容器目录:/var/lib/doc ...

  5. 将当前容器保存为本地镜像

    将容器保存为本地镜像又叫做容器的持久化存储,docker 镜像导入导出有两种方法:一种是使用 save 和 load 命令:一种是使用 export 和 import 命令. 二者的区别在于: Sav ...

  6. 容器学习 之 扩展镜像(五)

    Dockerfile 是一个文本文件,记录了镜像构建的所有步骤. 创建Dockerfile 用 Dockerfile 创建上节的 ubuntu-with-vi,其内容则为: 下面我们运行 docker ...

  7. 容器学习 之 base镜像(四)

    上一节我们谈到了容器的组件,镜像是 Docker 容器的基石,容器是镜像的运行实例,有了镜像才能启动容器. 这里我们先从base镜像开始一步步了解镜像的内部构造,镜像的分层,镜像的分发和管理. 我们以 ...

  8. Docker学习笔记之保存和共享镜像

    0x00 概述 让 Docker 引以为傲的是它能够实现相比于其他虚拟化软件更快的环境迁移和部署,在这件事情上,轻量级的容器和镜像结构的设计无疑发挥了巨大的作用.通过将容器打包成镜像,再利用体积远小于 ...

  9. Docker私有仓库管理,删除本地仓库中的镜像

    一:Docker私有仓库安装 1. 下载镜像是有镜像仓库: [root@localhost ~]# systemctl start docker#如果已经有镜像了,强制删除原来的镜像的方式如下: [r ...

最新文章

  1. linux进程自动关闭与dmesg的使用
  2. testing your idea
  3. BNU 26349——Cards——————【区间dp】
  4. 统计数字字符个数(信息学奥赛一本通-T1129)
  5. PHP获取URL完整路径及物理路径
  6. html中隐式转换成数字,详解JS中的隐式类型转换
  7. 云服务器如何选型?可以从这几个方面来考虑
  8. c语言学习建议,学习c语言的建议
  9. 激光雷达RPLIDAR A1使用教程
  10. 蜂鸣器电路设计中选用注意事项--【电路设计】
  11. 广数工业机器人五点法_盘点:国产工业机器人“四小龙”新业绩经营情况
  12. vue代码怎么变成小程序_从项目中由浅入深的学习vue,微信小程序和快应用 (1)
  13. 200个句子搞定3500个高考词汇,究竟有多少词?
  14. CRMchat 客服系统
  15. 可爱的树链剖分(染色)
  16. Android 人脸解锁源码剖析
  17. 【ubuntu】Ubuntu 安装中文输入法
  18. mysql 人员查询总结
  19. 韩国要对机器人征税,因为它们取代了人类工作
  20. 完美VS2010黑色主题最舒服的护眼主题(包含所需插件)

热门文章

  1. 【Boost】boost库中智能指针——shared_ptr
  2. 彻彻底底了解回调函数
  3. STL中list用法详解
  4. 一文读懂浏览器存储与缓存机制
  5. C++ STL : 模拟实现STL中的vector类
  6. 重学 Java 之 5种字符流读取方法
  7. 音视频技术开发周刊 | 171
  8. 感谢有你 WebRTCon 2018优秀出品人、讲师与志愿者
  9. 从C++转向最受欢迎的Rust语言
  10. 邀您参加 | K8S云原生技术开放日-北京站