参考:

https://docs.docker.com/engine/reference/builder/

https://hub.docker.com/_/registry/

https://www.cnblogs.com/vikings-blog/p/3972370.html

https://docs.docker.com/registry/deploying/#customize-the-published-port

针对registry的理解,我们可以类比github.com,网站。

在本地搭建git服务器,自已的私有仓库。当然公司内部也有需要,在公司内部搭建registry服务

按如下操作可实现本地搭建docker registry

1. 运行私有仓库的镜像管理服务registry
root@vmuser-virtual-machine:/home/vmuser# docker run -d -p 5000:5000 –restart always –name registry registry:2.6.2
Unable to find image ‘registry:2.6.2’ locally
2.6.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.6.2
68448c14a29ce0bcd07fc2edcf387dc216ed87a36d9eac8db8acfaa0b3c2406b
root@vmuser-virtual-machine:/home/vmuser# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68448c14a29c registry:2.6.2 “/entrypoint.sh /etc…” 37 seconds ago Up 36 seconds 0.0.0.0:5000->5000/tcp registry

2. 查看当前的厂库镜像
安装registry-cli及相关的依赖:
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker# git clone https://github.com/andrey-pohilko/registry-cli
正克隆到 ‘registry-cli’…
remote: Counting objects: 276, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 276 (delta 4), reused 6 (delta 2), pack-reused 264
接收对象中: 100% (276/276), 103.26 KiB | 190.00 KiB/s, 完成.
处理 delta 中: 100% (138/138), 完成.
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# pip install requests
Collecting requests
Downloading https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB)
100% |████████████████████████████████| 92kB 162kB/s
Requirement already satisfied: idna<2.8,>=2.5 in /usr/lib/python2.7/dist-packages (from requests)
Collecting certifi>=2017.4.17 (from requests)
Downloading https://files.pythonhosted.org/packages/df/f7/04fee6ac349e915b82171f8e23cee63644d83663b34c539f7a09aed18f9e/certifi-2018.8.24-py2.py3-none-any.whl (147kB)
100% |████████████████████████████████| 153kB 501kB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 1.7MB/s
Collecting urllib3<1.24,>=1.21.1 (from requests)
Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 2.1MB/s
Installing collected packages: certifi, chardet, urllib3, requests
Successfully installed certifi-2018.8.24 chardet-3.0.4 requests-2.19.1 urllib3-1.23

开启registry服务:

root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# python registry.py -r http://localhost:5000
Traceback (most recent call last):
File “registry.py”, line 13, in <module>
import www_authenticate  --- 缺少相关的python库,我们手动安装下
ImportError: No module named www_authenticate
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# pip install www_authenticate
Collecting www_authenticate
Downloading https://files.pythonhosted.org/packages/a7/2d/5567291a8274ef5d9b6495a1ec341394ab68933e2396936755b157f87b43/www-authenticate-0.9.2.tar.gz
Building wheels for collected packages: www-authenticate
Running setup.py bdist_wheel for www-authenticate … done
Stored in directory: /root/.cache/pip/wheels/dd/64/7f/62727305e6bba21e34bbdb8017d4770b6109d8028463454a35
Successfully built www-authenticate
Installing collected packages: www-authenticate
Successfully installed www-authenticate-0.9.2
因为当前的厂库为空,所以如下显示无显示:
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# python registry.py -r http://localhost:5000

3 将docker ubuntu:16.04 下载至本地,并查看,并将其上传至本地registry,然后下载至本地
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# docker pull ubuntu:16.04
16.04: Pulling from library/ubuntu
3b37166ec614: Pull complete
504facff238f: Pull complete
ebbcacd28e10: Pull complete
c7fb3351ecad: Pull complete
2e3debadcbf7: Pull complete
Digest: sha256:45ddfa61744947b0b8f7f20b8de70cbcdd441a6a0532f791fd4c09f5e491a8eb
Status: Downloaded newer image for ubuntu:16.04
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# docker tag ubuntu:16.04 localhost:5000/myubuntu:16.04

root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# docker push localhost:5000/myubuntu:16.04
The push refers to repository [localhost:5000/myubuntu]
75b79e19929c: Pushed
4775b2f378bb: Pushed
883eafdbe580: Pushed
19d043c86cbc: Pushed
8823818c4748: Pushed
16.04: digest: sha256:9b47044b1e79b965a8e1653e7f9c04b5f63e00b9161bedd5baef69bb8b4c4834 size: 1357

通过如下命令可查看到本地的docker registry存在的docker镜像:
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# python registry.py -r http://localhost:5000
———————————
Image: myubuntu
tag: 16.04

通过如下指令拉下来,测试存在本地的docker registry是否可以运行?
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# docker pull localhost:5000/myubuntu:16.04
16.04: Pulling from myubuntu
Digest: sha256:9b47044b1e79b965a8e1653e7f9c04b5f63e00b9161bedd5baef69bb8b4c4834
Status: Image is up to date for localhost:5000/myubuntu:16.04
root@vmuser-virtual-machine:/home/vmuser/workdir/registry-docker/registry-cli# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry 2.6.2 2e2f252f3c88 4 days ago 33.3MB
localhost:5000/myubuntu 16.04 b9e15a5d1e1a 10 days ago 115MB
ubuntu latest cd6d8154f1e1 10 days ago 84.1MB

learning docker steps(7) ----- docker registry 搭建的更多相关文章

  1. learning docker steps(8) ----- docker network 初次体验

    参考: docker network 主要是介绍了docker 容器之间的组网模式, 一般来说实像组网主要是依赖于bridge iptalbes vlan来实现,但是附带的如端口转发会降低效率. 新型 ...

  2. learning docker steps(2) ----- docker contailner 初次体验

    参考:https://docs.docker-cn.com/get-started/part2/ Dockerfile的内容如下所示: # 将官方 Python 运行时用作父镜像 FROM pytho ...

  3. learning docker steps(1) ----- docker 安装

    docker 安装 参考:https://docs.docker.com/install/linux/docker-ce/ubuntu/ 按如下指令可安装: $ sudo apt-get instal ...

  4. learning docker steps(6) ----- docker 镜像加速

    http://www.docker-cn.com/registry-mirror 通过 Docker 官方镜像加速,中国区用户能够快速访问最流行的 Docker 镜像.该镜像托管于中国大陆,本地用户现 ...

  5. learning docker steps(5) ----- docker stack 初次体验

    参考:https://docs.docker.com/get-started/part5/ stack 技术栈.技术栈是一组相关的服务,它们共享依赖项并且可以一起进行编排和扩展.单个技术栈能够定义和协 ...

  6. learning docker steps(4) ----- docker swarm 初次体验

    参考:https://docs.docker.com/get-started/part4/ 了解 swarm 集群 swarm 是一组运行 Docker 并且已加入集群中的机器.执行此操作后,您可以继 ...

  7. learning docker steps(3) ----- docker services 初次体验

    参考:https://docs.docker.com/get-started/part3/#docker-composeyml docker 的 service样例, 我们可以理解成是一个本地负载均衡 ...

  8. docker registry 搭建

    registry 搭建 假设在 cd /root 目录下 最新 docker run -d -p 5000:5000 -v pwd/data:/var/lib/registry --restart=a ...

  9. Ubuntu Docker Registry 搭建私有仓库

    服务器版本 Ubuntu 16.04 LTS. 安装命令: $ docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --rest ...

随机推荐

  1. FATFS(A)

    (一),什么是文件管理系统 答:数据在PC上是以文件的形式储存在磁盘中的,这些数据的形式一般为ASCII码或二进制形式.简单点说就是:管理磁盘上的文件的方法的代码! 如:我们写到SD卡上面的数据管理一 ...

  2. Python3基础 yield 在函数中的用法示例

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. linux下精确替换某个字符串

    1.linux下精确替换某个字符串 sed -i 's/\<old\>/new/g' filename.txt 2.举例: 2.1有个文件名为filename.txt,内容如下: newd ...

  4. windows下的gvim和emmet 下载和安装 + "omnifunc is not set" solution?

    注意几个地方: 引导键是ctrl-y, 其他就是实际的操作键了, 如: n下一个插入点, N是上一个插入点(不是p), ctrl-y + i是自动为图片添加宽度和高度尺寸, 要点是要把光标移动到 im ...

  5. HDU 1686 Oulipo(KMP)题解

    题意:主串中能找到几个模式串 思路:超详细解释KMP KMP:针对这个代码,解释一下Fail数组的含义:T为主串,P为模式串,Fail代表失配值,即当P[j] != T[i]时,j要指向的位置为Fai ...

  6. HDU1540 Tunnel Warfare(线段树区间维护&求最长连续区间)题解

    Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  7. 【建表】ElasticSearch建表命令

    使用google插件Postman 发送方式为PUT,url地址: 192.168.2.11:9200/IndexName 文本raw,数据为json格式 { "settings" ...

  8. 【TCP/IP详解 卷一:协议】第一章概论 学习笔记

    第一章 概述 游览了一下,本章主要是简介OSI模型的低层(1-4层).介绍了TCP/IP协议族的相关知识. TCP/IP的分层 Application <--> TCP / UDP < ...

  9. Python实现自平衡二叉树AVL

    # -*- coding: utf-8 -*- from enum import Enum #参考http://blog.csdn.net/niteip/article/details/1184069 ...

  10. HDU 5873 Football Games(竞赛图兰道定理)

    http://acm.hdu.edu.cn/showproblem.php?pid=5873 题意: 现在有比赛,所有队伍两两进行比赛,赢的积2分,输的积0分,如果平局的话就各自都积1分,现在给出每只 ...