分享

搭建私有Docker Registry

hochikong 发表于 2015-2-16 14:55:55 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 33873
问题导读:
1.Docker Registry有哪几种flavors?
2.变量SETTINGS_FLAVOR的作用是什么?
3.如何下载某台机器上配置的Registry上的image?

Docker的Docker Hub是一个公有的Registry, 从Docker Hub上可以找到很多的官方或个人构建的Docker Image, 通常, 这些image能满足开发、测试的需求.  但是如果想构建的image只在控制范围内共享, 而不是开放环境, 那就得搭建自己的私有Docker Registry. Docker官方实现了docker-registy, 根据官方的说明可以搭建自己的Docker Registry, 官方有两种方式搭建Docker Registry, 一种是按传统的部署软件的方法安装Docker Registry,  详细可参考Matthew Fisher的博客, 另一种是通过官方构建的Docker image来搭建Docker Registry. 本文简单介绍如何通过官方Docker image搭建自己的私有Docker Registry.

第一步: 下载官方Registry Docker Image
  1. docker pull registry:latest
复制代码



第二步: 准备配置文件

创建配置文件
Docker Registry自带一个config_sample.yml配置文件, 通常将这个文件重命名为config.yml作为基本配置文件.

配置flavors
Docker Registry可以以几种flavors运行, 这使得Docker Registry可以运行在开发模式, 产线模式或者自定义的模式. 从配置文件config_sample.yml可知包括如下的一些flavors.
common:  作为其他flavors的基本配置.
local:  将数据存放在本地文件系统.
s3: 使用AWS S3存放数据.
dev: 使用local flavor作为基本配置.
test: 作为单元测试的flavor.
prod: 默认使用s3 flavor作为产线配置.

除此之外, 也可以使用OpenStack的swift, glance, glance-swift来存放数据, 还有key/value存储elliptics, 以及Google Cloud Storage GCE来存放数据.  除前所述的内置flavors, 也可以自定义flavor. 下面是一个简单config.yml配置文件:
  1. common:
  2.     loglevel: info
  3.     search_backend: "_env:SEARCH_BACKEND:"sqlalchemy_index_database:"_env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db"prod:
  4.     loglevel: warn
  5.     storage: s3
  6.     s3_access_key: _env:AWS_S3_ACCESS_KEY
  7.     s3_secret_key: _env:AWS_S3_SECRET_KEY
  8.     s3_bucket: _env:AWS_S3_BUCKET
  9.     boto_bucket: _env:AWS_S3_BUCKET
  10.     storage_path: /srv/docker
  11.     smtp_host: localhost
  12.     from_addr: docker@myself.com
  13.     to_addr: my@myself.com
  14. dev:
  15.     loglevel: debug
  16.     storage: local
  17.     storage_path: /home/myself/docker
  18. test:
  19.     storage: local
  20.     storage_path: /tmp/tmpdockertmp
复制代码



Docker Registry的默认运行环境是dev, 如果你需要更改运行环境, 可通过环境变量SETTINGS_FLAVOR来指定, 例如, 通过执行如下可设定运行环境为prod.
  1. export SETTINGS_FLAVOR=prod
复制代码



指定配置文件位置
Docker Registry运行时可以通过环境变量DOCKER_REGISTRY_CONFIG指定config.yml的默认路径,  例如指定config.yml的默认位置为/opt/docker-registry/conf如下:

  1. export DOCKER_REGISTRY_CONFIG=/opt/docker-registy/conf/config.yml
复制代码



配置选项
通用配置选项包括loglevel, debug_versions, storage_redirect等, 其中logleve可以设置为info, debug, warn, error和critical级别.

  1. # Default log level is infologlevel: _env:LOGLEVEL:info
复制代码



授权选项包括standalone, index_endpoint和disable_token_auth等, standalone用来设定Docker Registry server为stand-alone模式, index_endpoint配置index endpoint的hostname, 通常用来验证用户登录时的密码, 默认是https://index.docker.io.
  1. # By default, the registry acts standalone (eg: doesn't query the index)standalone: _env:STANDALONE:true# The default endpoint to use (if NOT standalone) is index.docker.ioindex_endpoint: _env:INDEX_ENDPOINT:https://index.docker.io# Token auth is enabled (if NOT standalone)disable_token_auth: _env:DISABLE_TOKEN_AUTH
复制代码



搜索引擎选项search_backend用来设定后台搜索引擎, 如果为空, 则没有索引, 当前支持的backend为sqlalchemy.
  1. # No search backendsearch_backend: _env:SEARCH_BACKEND# SQLite search backendsqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db
复制代码



存储选项storage设置存储引擎, Docker Registry默认存储引擎为file和s3, 也可以通过pip install docker-registry-driver-STORAGE_NAME来安装其他storage, 比如swift, gcs, glance等, 然后配置storage为STORAGE_NAME, 跟storage选项一起使用的是storage_path, 其用来指定存储数据的路径, 比如: /registry.
  1. local:
  2.   storage: file
  3.   storage_path: /mnt/registry
  4.   
  5. prod:
  6.   storage: s3
  7.   s3_region: us-west-1
  8.   s3_bucket: acme-docker
  9.   storage_path: /registry
  10.   s3_access_key: AKIAHSHB43HS3J92MXZ
  11.   s3_secret_key: xdDowwlK7TJajV1Y7EoOZrmuPEJlHYcNP2k4j49T
复制代码




第三步: 运行Docker Registry
准备Docker Registry的配置文件路径以及在dev, test, prod模式下存放images的路径.

  1. mkdir -p /opt/docker-registry/{conf,dev,test,prod}
复制代码



配置config.yml文件如下:
  1. registry.db# Enable bugsnag (set the API key)    bugsnag: _env:BUGSNAG
  2. local: &local<<: *common
  3.     storage: local# This is the default configuration when no flavor is specifieddev: &dev<<: *local
  4.     loglevel: _env:LOGLEVEL:debug
  5.     debug_versions: _env:DEBUG_VERSIONS:true
  6.     search_backend: _env:SEARCH_BACKEND:sqlalchemy
  7.     storage_path: _env:STORAGE_PATH:/opt/docker-registry/dev# This flavor is used by unit teststest:<<: *dev
  8.     standalone: true
  9.     storage_path: _env:STORAGE_PATH:/opt/docker-registry/test# To specify another flavor, set the environment variable SETTINGS_FLAVOR# $ export SETTINGS_FLAVOR=prodprod:<<: *dev
  10.     storage_path: _env:STORAGE_PATH:/opt/docker-registry/prod
复制代码




运行Docker Registry(dev模式)
  1. docker run  -p 5000:5000 -v /opt/docker-registry/conf/:/opt/docker-registry/conf/  -v /opt/docker-registry/dev:/opt/docker-registry/dev --name=test-docker-registry -e DOCKER_REGISTRY_CONFIG=/opt/docker-registry/conf/config.yml registry
复制代码




其中设置volume /opt/docker-registry/dev为本地数据存储目录, –e DOCKER_REGISTRY_CONFIG=/opt/docer-registry/conf/config.yml为配置文件, 最后运行输出如下:
  1. 2014-09-16 15:02:28,547 WARNING: Cache storage disabled!2014-09-16 15:02:28,548 WARNING: LRU cache disabled!2014-09-16 15:02:28,553 DEBUG: Will return docker-registry.drivers.file.Storage2014-09-16 15:02:29 [1] [INFO] Starting gunicorn 18.02014-09-16 15:02:29 [1] [INFO] Listening at: http://0.0.0.0:5000 (1)2014-09-16 15:02:29 [1] [INFO] Using worker: gevent2014-09-16 15:02:29 [14] [INFO] Booting worker with pid: 142014-09-16 15:02:29 [15] [INFO] Booting worker with pid: 152014-09-16 15:02:29 [18] [INFO] Booting worker with pid: 182014-09-16 15:02:29 [19] [INFO] Booting worker with pid: 192014-09-16 15:02:29,361 WARNING: Cache storage disabled!2014-09-16 15:02:29,362 WARNING: LRU cache disabled!2014-09-16 15:02:29,374 DEBUG: Will return docker-registry.drivers.file.Storage2014-09-16 15:02:29,575 WARNING: Cache storage disabled!2014-09-16 15:02:29,576 WARNING: LRU cache disabled!2014-09-16 15:02:29,578 DEBUG: Will return docker-registry.drivers.file.Storage2014-09-16 15:02:29,595 WARNING: Cache storage disabled!2014-09-16 15:02:29,596 WARNING: LRU cache disabled!2014-09-16 15:02:29,598 DEBUG: Will return docker-registry.drivers.file.Storage2014-09-16 15:02:29,628 WARNING: Cache storage disabled!2014-09-16 15:02:29,629 WARNING: LRU cache disabled!2014-09-16 15:02:29,631 DEBUG: Will return docker-registry.drivers.file.Storage
复制代码



上传image:
  1. <blockquote>docker tag busybox 10.224.106.43:5000/busybox
复制代码



与此同时, 你能在Docker Registry container运行的终端看到上传busybox的日志记录, 如:
  1. 10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/_ping HTTP/1.1" 200 4 "-" "Go 1.1 package http"2014-09-16 15:07:54,129 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/_ping HTTP/1.1" 200 4 "-" "Go 1.1 package http"2014-09-16 15:07:54,133 DEBUG: args = {'namespace': 'library', 'repository': u'busybox'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/repositories/busybox/ HTTP/1.1" 200 2 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,167 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/repositories/busybox/ HTTP/1.1" 200 2 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,170 DEBUG: args = {'image_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}2014-09-16 15:07:54,172 DEBUG: api_error: Image not found10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,173 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,174 DEBUG: args = {'image_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,176 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,260 DEBUG: args = {'image_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,262 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,263 DEBUG: args = {'image_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,265 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,266 DEBUG: args = {'image_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}2014-09-16 15:07:54,267 DEBUG: api_error: Image not found10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,268 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,269 DEBUG: args = {'image_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,271 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,322 DEBUG: args = {'image_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,324 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,325 DEBUG: args = {'image_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,327 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,328 DEBUG: args = {'image_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}2014-09-16 15:07:54,329 DEBUG: api_error: Image not found10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,329 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "GET /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,331 DEBUG: args = {'image_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,333 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:54,566 DEBUG: args = {'image_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,105 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,107 DEBUG: args = {'image_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,109 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,111 DEBUG: args = {'image_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}2014-09-16 15:07:55,112 DEBUG: api_error: Image not found10.224.106.43 - - [16/Sep/2014:15:07:55] "GET /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,112 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "GET /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/json HTTP/1.1" 404 28 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,114 DEBUG: args = {'image_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,116 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/json HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,197 DEBUG: args = {'image_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,199 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/layer HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,201 DEBUG: args = {'image_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,202 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/images/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721/checksum HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,203 DEBUG: args = {'tag': u'latest', 'namespace': 'library', 'repository': u'busybox'}2014-09-16 15:07:55,204 DEBUG: [put_tag] namespace=library; repository=busybox; tag=latest10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/repositories/busybox/tags/latest HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,205 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/repositories/busybox/tags/latest HTTP/1.1" 200 4 "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,206 DEBUG: args = {'images': True, 'namespace': 'library', 'repository': u'busybox'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/repositories/busybox/images HTTP/1.1" 204 - "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"2014-09-16 15:07:55,232 INFO: 10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/repositories/busybox/images HTTP/1.1" 204 - "-" "docker/1.0.0 go/go1.2.2 kernel/3.10.0-123.el7.x86_64 os/linux arch/amd64"
复制代码




除此之外你也可以在浏览器上输入http://10.224.106.43:5000看到Docker Registry的运行模式, 当前运行模式为dev, 其输出信息如"docker-registry server (dev) (v0.8.1)".这时在/opt/docker-registry/dev目录下, 你能看到两个新的目录images和repositories, 这是新上传busybox的信息. 而且你可以在其他机器上从Docker Registry(10.224.106.43)上下载刚上传的image. 如:
  1. <blockquote>[root@docker02 ~]# docker pull 10.224.106.43:5000/busyboxPulling repository 10.224.106.43:5000/busybox
复制代码



运行Docker Registry(prod模式)
通过环境变量SETTINGS_FLAVOR使得Docker Registry以prod模式运行, 运行命令如:
  1. docker run -d -p 5000:5000 -v /opt/docker-registry/conf/:/opt/docker-registry/conf/  -v /opt/docker-registry/prod:/opt/docker-registry/prod --name=test-docker-registry -e DOCKER_REGISTRY_CONFIG=/opt/docker-registry/conf/config.yml -e SETTINGS_FLAVOR=prod registry
复制代码



这时如果上传image,你能在/opt/docker-registry/prod下发现新上传的image数据, 而且也可以从其他机器下载新上传的image.
  1. [root@golang conf]# docker push 10.224.106.43:5000/busyboxThe push refers to a repository [10.224.106.43:5000/busybox] (len: 1)
  2. Sending image list
  3. Pushing repository 10.224.106.43:5000/busybox (1 tags)
  4. 511136ea3c5a: Image successfully pushed
  5. 42eed7f1bf2a: Image successfully pushed
  6. 120e218dd395: Image successfully pushed
  7. a9eb17255234: Image successfully pushed
  8. Pushing tag for rev [a9eb17255234] on {http://10.224.106.43:5000/v1/repositories/busybox/tags/latest}
  9. [root@golang prod]# pwd/opt/docker-registry/prod
  10. [root@golang prod]# lltotal 4drwxr-xr-x. 6 root root 4096 Sep 16 11:36 images
  11. drwxr-xr-x. 3 root root   20 Sep 16 11:36 repositories
  12. [root@docker02 ~]# docker pull 10.224.106.43:5000/busyboxPulling repository 10.224.106.43:5000/busybox
  13. a9eb17255234: Download complete
  14. 511136ea3c5a: Download complete
  15. 42eed7f1bf2a: Download complete
  16. 120e218dd395: Download complete
复制代码





####################################################
本文转自:http://aresy.blog.51cto.com/5100031/1553624




欢迎加入about云群9037177932227315139327136 ,云计算爱好者群,亦可关注about云腾讯认证空间||关注本站微信

没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条