docker HUB提供了registry的image, 可以非常方便的搭建私有regisrty.
当然你也可以选择从docker-registry的源码来搭建. 见 : https://github.com/docker/docker-registry
本文主要说一下使用docker registry image搭建私有registry.
1. 首先要部署docker
参考 : 
https://docs.docker.com/installation/#installation
2. 启动docker 服务端, 最好使用-g 设置好root路径.
参考 : 
http://blog.163.com/digoal@126/blog/static/16387704020149303488635/
3. 然后从docker hub 下载registry镜像到本地.

[root@db-172-16-3-221 ~]# docker pull registry
[root@db-172-16-3-221 ~]# docker images registry
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
registry            0.8.1               3e7767ddd728        9 days ago          427.9 MB
registry            0.7.3               c723c9b95ac0        9 days ago          424.1 MB
registry            latest              8e9a29f977a7        9 days ago          427.9 MB
registry            0.6.9               bee70978874c        9 days ago          461.9 MB
registry            0.8.0               cd3581c06bdc        11 weeks ago        442.5 MB
registry            0.6.8               346f0c4d40c3        4 months ago        447.8 MB
registry            0.7.2               8b65881eed3d        4 months ago        516 MB
registry            0.7.0               a6a394071526        4 months ago        516 MB
registry            0.7.1               cc32522f16d6        4 months ago        516 MB
registry            0.6.7               cd8d7a6d86d1        5 months ago        452.5 MB
registry            0.6.6               e260f5a77e52        6 months ago        443 MB
registry            0.6.5               e7bac0a3804b        7 months ago        433 MB
registry            0.6.3               1f7bbd131cd8        9 months ago        490 MB
registry            0.6.2               0b520d776e7d        9 months ago        466.6 MB
registry            0.6.1               9f98cb899f46        9 months ago        460.1 MB
registry            0.6.0               873f518b98ef        9 months ago        466.5 MB
registry            0.5.9               e8e5377f8307        9 months ago        466.3 MB
registry            0.6.4               b04ace768d59        9 months ago        490 MB

4. 使用registry image启动container. 启动时最好指定卷(用于存储镜像), 端口映射.
创建目录, 用于存储镜像

[root@db-172-16-3-221 ~]# mkdir /data01/registry_sto
[root@db-172-16-3-221 ~]# mkdir /data01/registry_conf

创建配置文件, 从https://github.com/docker/docker-registry/blob/master/config/config_sample.yml下载

[root@db-172-16-3-221 ~]# cd /data01/registry_conf
[root@db-172-16-3-221 registry_conf]# vi config_sample.yml
# 把https://github.com/docker/docker-registry/blob/master/config/config_sample.yml的内容写入该文件.
# 须修改几处, 本文使用本地存储, local配置. (为了使search可用, 必须设置search backend)
    issue: '"Digoal`s docker-registry server"'local: &local<<: *commonstorage: localstorage_path: _env:STORAGE_PATH:/registry_stosearch_backend: _env:SEARCH_BACKEND:sqlalchemysqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:tmp/docker-registry.db

5. 启动container, 指定网络, 指定端口映射, 指定卷, 环境变量(配置文件,存储路径),
先使用前台启动, 调试正常后, 加上-d 后台启动.
docker run -d --net="host" -p 5000:5000 -v /data01/registry_conf:/registory_conf -v /data01/registry_sto:/registry_sto -e DOCKER_REGISTRY_CONFIG=/registory_conf/config_sample.yml -e STORAGE_PATH=/registry_sto -e SETTINGS_FLAVOR=local --name=registry  registry:0.8.1[root@db-172-16-3-221 registry_conf]# docker run --net="host" -p 5000:5000 -v /data01/registry_conf:/registory_conf -v /data01/registry_sto:/registry_sto -e DOCKER_REGISTRY_CONFIG=/registory_conf/config_sample.yml -e STORAGE_PATH=/registry_sto -e SETTINGS_FLAVOR=local --name=registry  registry:0.8.1
2014-11-03 02:26:50,648 WARNING: Cache storage disabled!
2014-11-03 02:26:50,648 WARNING: LRU cache disabled!
2014-11-03 02:26:50 [1] [INFO] Starting gunicorn 18.0
2014-11-03 02:26:50 [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
2014-11-03 02:26:50 [1] [INFO] Using worker: gevent
2014-11-03 02:26:50 [15] [INFO] Booting worker with pid: 15
2014-11-03 02:26:50 [16] [INFO] Booting worker with pid: 16
2014-11-03 02:26:50 [17] [INFO] Booting worker with pid: 17
2014-11-03 02:26:51 [22] [INFO] Booting worker with pid: 22
2014-11-03 02:26:51,022 WARNING: Cache storage disabled!
2014-11-03 02:26:51,023 WARNING: LRU cache disabled!
2014-11-03 02:26:51,030 WARNING: Cache storage disabled!
2014-11-03 02:26:51,031 WARNING: LRU cache disabled!
2014-11-03 02:26:51,105 WARNING: Cache storage disabled!
2014-11-03 02:26:51,106 WARNING: LRU cache disabled!
2014-11-03 02:26:51,193 WARNING: Cache storage disabled!
2014-11-03 02:26:51,193 WARNING: LRU cache disabled![root@db-172-16-3-221 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
5c64e3cb2fd8        registry:0.8.1      /bin/sh -c 'exec doc   22 seconds ago      Up 21 seconds                           registry
[root@db-172-16-3-221 ~]# docker inspect registry
[{"Args": ["-c","exec docker-registry"],"Config": {"AttachStderr": true,"AttachStdin": false,"AttachStdout": true,"Cmd": ["/bin/sh","-c","exec docker-registry"],"CpuShares": 0,"Cpuset": "","Domainname": "","Entrypoint": null,"Env": ["DOCKER_REGISTRY_CONFIG=/registory_conf/config_sample.yml","STORAGE_PATH=/registry_sto","SETTINGS_FLAVOR=local","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"ExposedPorts": {"5000/tcp": {}},"Hostname": "db-172-16-3-221","Image": "registry:0.8.1","Memory": 0,"MemorySwap": 0,"NetworkDisabled": false,"OnBuild": null,"OpenStdin": false,"PortSpecs": null,"StdinOnce": false,"Tty": false,"User": "","Volumes": null,"WorkingDir": ""},"Created": "2014-11-03T02:26:49.936106407Z","Driver": "devicemapper","ExecDriver": "native-0.2","HostConfig": {"Binds": ["/data01/registry_conf:/registory_conf","/data01/registry_sto:/registry_sto"],"ContainerIDFile": "","Dns": null,"DnsSearch": null,"Links": null,"LxcConf": [],"NetworkMode": "host","PortBindings": {"5000/tcp": [{"HostIp": "","HostPort": "5000"}]},"Privileged": false,"PublishAllPorts": false,"VolumesFrom": null},"HostnamePath": "/data01/docker/containers/5c64e3cb2fd8c3160c953a4708b31aeb9900eefc40787e3e565c099e977f1e1f/hostname","HostsPath": "/data01/docker/containers/5c64e3cb2fd8c3160c953a4708b31aeb9900eefc40787e3e565c099e977f1e1f/hosts","Id": "5c64e3cb2fd8c3160c953a4708b31aeb9900eefc40787e3e565c099e977f1e1f","Image": "3e7767ddd728c1480e9bcfd5fdbe453b57f948deca3f55c9ef0459f9d24720a1","MountLabel": "","Name": "/registry","NetworkSettings": {"Bridge": "","Gateway": "","IPAddress": "","IPPrefixLen": 0,"PortMapping": null,"Ports": null},"Path": "/bin/sh","ProcessLabel": "","ResolvConfPath": "/etc/resolv.conf","State": {"ExitCode": 0,"FinishedAt": "0001-01-01T00:00:00Z","Paused": false,"Pid": 29578,"Running": true,"StartedAt": "2014-11-03T02:26:50.167293486Z"},"Volumes": {"/registory_conf": "/data01/registry_conf","/registry_sto": "/data01/registry_sto"},"VolumesRW": {"/registory_conf": true,"/registry_sto": true}
}
]
好了, 如果防火墙允许的话, 可以连接到这个私有的HUB了.
IE
6. 测试 : 
6.1 首先测试push image到这个registry.
当然要先制作image, 制作image可以通过现有的image或者通过dockerfile来制作, 略.
假设当前已有的image如下, 我想把centos:centos6 push到刚刚搭建的私有docker registry.
[root@db-172-16-3-221 ~]# docker images centos
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              centos5             504a65221a38        4 weeks ago         467.1 MB
centos              centos6             68edf809afe7        4 weeks ago         212.7 MB
centos              centos7             87e5b6b3ccc1        4 weeks ago         224 MB
centos              latest              87e5b6b3ccc1        4 weeks ago         224 MB

首先要打上tag
docker tag [-f|--force[=false]] IMAGE [REGISTRYHOST/][USERNAME/]NAME[:TAG]
如下, 
[root@db-172-16-3-221 ~]# docker tag 68edf809afe7 172.16.3.221:5000/centos:centos6
[root@db-172-16-3-221 ~]# docker push 172.16.3.221:5000/centos:centos6
The push refers to a repository [172.16.3.221:5000/centos] (len: 1)
Sending image list
Pushing repository 172.16.3.221:5000/centos (1 tags)
511136ea3c5a: Image successfully pushed
5b12ef8fd570: Image successfully pushed
68edf809afe7: Image successfully pushed
Pushing tag for rev [68edf809afe7] on {http://172.16.3.221:5000/v1/repositories/centos/tags/centos6}[root@db-172-16-3-221 data01]# cd registry_sto/
[root@db-172-16-3-221 registry_sto]# ll
total 4
drwxr-xr-x 5 root root 4096 Nov  3 10:41 images
drwxr-xr-x 3 root root   20 Nov  3 10:41 repositories
[root@db-172-16-3-221 registry_sto]# du -sh *
73M     images
12K     repositories

或存放到用户下(方便辨识是谁上传的, 或者归类) :

[root@150 ~]# docker tag 504a65221a38 172.16.3.221:5000/digoal/centos:centos5
[root@150 ~]# docker push 172.16.3.221:5000/digoal/centos:centos5
The push refers to a repository [172.16.3.221:5000/digoal/centos] (len: 1)
Sending image list
Pushing repository 172.16.3.221:5000/digoal/centos (1 tags)
Image 511136ea3c5a already pushed, skipping
Image 5b12ef8fd570 already pushed, skipping
504a65221a38: Image successfully pushed
Pushing tag for rev [504a65221a38] on {http://172.16.3.221:5000/v1/repositories/digoal/centos/tags/centos5}

6.2 测试从私有registry pull image到本地

[root@150 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
digoal/pg           9.3.5               b8a933b7f4d7        10 days ago         646.5 MB
centos              centos5             504a65221a38        4 weeks ago         467.1 MB
centos              centos7             87e5b6b3ccc1        4 weeks ago         224 MB
centos              latest              87e5b6b3ccc1        4 weeks ago         224 MB
[root@150 ~]# docker pull 172.16.3.221:5000/centos:centos6
Pulling repository 172.16.3.221:5000/centos
68edf809afe7: Download complete
511136ea3c5a: Download complete
5b12ef8fd570: Download complete
注意repository列, 从私有registry下载的image很容易辨识.
[root@150 ~]# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
digoal/pg                  9.3.5               b8a933b7f4d7        10 days ago         646.5 MB
centos                     centos5             504a65221a38        4 weeks ago         467.1 MB
172.16.3.221:5000/centos   centos6             68edf809afe7        4 weeks ago         212.7 MB
centos                     centos7             87e5b6b3ccc1        4 weeks ago         224 MB
centos                     latest              87e5b6b3ccc1        4 weeks ago         224 MB

6.3 使用私有registry下载的image run container :

[root@150 ~]# docker run -t -i --rm 172.16.3.221:5000/centos:centos6 /bin/bash
bash-4.1# w02:47:41 up 25 days, 22:48,  0 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
bash-4.1# uname -r
2.6.32-431.23.3.el6.x86_64
bash-4.1# cat /etc/redhat-release
CentOS release 6.5 (Final)

6.4 search , 使用方法如下 :

[root@150 ~]# curl -X GET http://172.16.3.221:5000/v1/search?q=centos
{"num_results": 2, "query": "centos", "results": [{"description": null, "name": "library/centos"}, {"description": null, "name": "digoal/centos"}]}
[root@150 ~]# curl -X GET http://172.16.3.221:5000/v1/search?q=digoal
{"num_results": 1, "query": "digoal", "results": [{"description": null, "name": "digoal/centos"}]}
结合openstack等云平台使用, 将镜像存储到云平台镜像管理存储, 可参考 : 
http://www.activestate.com/blog/2014/01/deploying-your-own-private-docker-registry

[参考]

1. http://blog.docker.com/2013/07/how-to-use-your-own-registry/
2. http://www.activestate.com/blog/2014/01/deploying-your-own-private-docker-registry
3. https://github.com/docker/docker-registry
4. https://github.com/docker/docker-registry/blob/master/ADVANCED.md
5. https://github.com/docker/docker-registry/blob/master/config/config_sample.yml
6. man docker-tag

deploy owned private docker registry based on docker HUB registry image相关推荐

  1. docker 查询或获取私有仓库(registry)中的镜像

    docker 查询或获取私有仓库(registry)中的镜像,使用 docker search 192.168.1.8:5000 命令经测试不好使. 解决: 1.获取仓库类的镜像: [root@sha ...

  2. Docker(六)Docker Hub+Docker Registry

    Docker Hub 提供了镜像托管服务,地址为https://hub.docker.com/ 利用Docker Hub用户可以搜索.创建.分享.管理镜像,一般有两大类:官方和用户自己上传镜像. 一. ...

  3. 使用Docker部署GitLab、Nexus、Registry私服

    使用Docker搭建GitLab.Nexus.Registry 最佳建议,一个服务器部署一个相应服务,如果服务器够强大,就可忽视忽视. GitLab的部署 下载镜像 GitLab社区中文版镜像地址 $ ...

  4. docker部署flask_使用Docker,GCP Cloud Run和Flask部署Scikit-Learn NLP模型

    docker部署flask A brief guide to building an app to serve a natural language processing model, contain ...

  5. Docker初学2:Docker的安装

    Docker的安装 Docker的架构图 我们先来介绍一下上面这张Docker架构图 镜像(image): Docker 镜像(Image)就是一个只读的模板.镜像可以用来创建 Docker 容器,一 ...

  6. docker学习笔记(一)docker入门

    目录 基本概念 docker引擎 docker架构 安装docker docker常用命令 Docker 是一个开源的应用容器引擎,它基于 Go 语言 并遵从 Apache2.0 协议开源. Dock ...

  7. docker 部署java_使用Docker堆栈部署的微服务-WildFly,Java EE和Couchbase

    docker 部署java 关于微服务的资料很多,只是用谷歌搜索就可以了 ! 几年前,我在比利时的Devoxx上发表了有关将单片重构为微服务的演讲,它获得了很好的评价: 该博客将展示Docker如何简 ...

  8. Docker学习之三:docker镜像管理

    Docker镜像 一个host可以启动多个容器,基于镜像可在容器中启动不同的应用.如果本地无此镜像,docker可自动连接到docker registry上下载镜像,存储到本地文件系统(如overla ...

  9. Docker 2.3:Docker 镜像管理

    2.3:Docker 镜像管理 2.3.1:docker search - 搜索镜像 如果要搜索镜像,更好的方式是直接在 Dockerhub 网页上进行搜索,命令行搜索结果并不直观: 基本搜索 会将含 ...

最新文章

  1. gnome Nautilus cannot handle computer locations
  2. 关于TP-LINK宽带路由器上的“转发规则”功能用途及设置办法
  3. 《算法导论》学习总结 — 2.第一章 第二章 第三章
  4. 二、linux命令(ubuntu)
  5. Xamarin.Forms 5.0 来了
  6. WebApiClient与Asp.net core DI的结合
  7. 在 Windows 下远程桌面连接 Linux - XManager 篇
  8. matlab 绘制三维离散点云,并根据Z值大小着色,matlab怎样画颜色随着Z大小变化的三维散点图
  9. (转)Android之发送短信的两种方式
  10. java实现k线图自动化_Python秒绘交互式股票K线图!这就是Python的优势!
  11. Adb connection Error: adb关闭,adb重启。BUG
  12. 用计算机做初中模拟物理实验,仿真物理实验室初中完整版
  13. autoreconf: command not found
  14. 浅谈JSONP跨域漏洞
  15. JZOJ4722. 跳楼机
  16. 牛刀小试-99乘法表
  17. tensorflow graphics详解
  18. Since Due to Because of Because 的用法和区别
  19. [Unity3d] [图文]【寻路】 Waypoint 与 NavMesh 比较(转)
  20. 关于win10系统中谷歌浏览器崩溃的问题

热门文章

  1. set和map去重调用什么方法_Es6中Map对象和Set对象的介绍及应用
  2. java树的基本知识_Java数据结构和算法(二)树的基本操作
  3. 单片机C语言稳压程序,51单片机的基于MC34063的5V稳压器的设计 -(原理图+程序)...
  4. asyncawait异步请求处理办法
  5. matlab怎么编写数据处理程序,【悬赏--已结束】求编写一个基于Matlab的数据处理程序...
  6. CSS修改默认列表元素样式(1.修改默认元素样式 2.伪元素选择器)
  7. 用Java语言编写的随机彩色验证码
  8. Ubuntu 安装 Apache Airflow
  9. mysql newid函数_sql随机函数newID()和RAND()详解
  10. linux测试dvi接口,TeX Live DVI字体数据解析整数溢出漏洞