Docker的Docker Hub是一個公有的Registry, 從Docker Hub上能夠找到不少的官方或我的構建的Docker Image, 一般, 這些p_w_picpath能知足開發、測試的需求. 可是若是想構建的p_w_picpath只在控制範圍內共享, 而不是開放環境, 那就得搭建本身的私有Docker Registry. Docker官方實現了docker-registy, 根據官方的說明能夠搭建本身的Docker Registry, 官方有兩種方式搭建Docker Registry, 一種是按傳統的部署軟件的方法安裝Docker Registry, 詳細可參考Matthew Fisher的博客, 另外一種是經過官方構建的Docker p_w_picpath來搭建Docker Registry. 本文簡單介紹如何經過官方Docker p_w_picpath搭建本身的私有Docker Registry.linux
docker pull registry:latest
建立配置文件git
Docker Registry自帶一個config_sample.yml配置文件, 一般將這個文件重命名爲config.yml做爲基本配置文件.github
配置flavorsgolang
Docker Registry能夠以幾種flavors運行, 這使得Docker Registry能夠運行在開發模式, 產線模式或者自定義的模式. 從配置文件config_sample.yml可知包括以下的一些flavors.sql
common: 做爲其餘flavors的基本配置.docker
local: 將數據存放在本地文件系統.json
s3: 使用AWS S3存放數據.swift
dev: 使用local flavor做爲基本配置.api
test: 做爲單元測試的flavor.瀏覽器
prod: 默認使用s3 flavor做爲產線配置.
除此以外, 也可使用OpenStack的swift, glance, glance-swift來存放數據, 還有key/value存儲elliptics, 以及Google Cloud Storage GCE來存放數據. 除前所述的內置flavors, 也能夠自定義flavor. 下面是一個簡單config.yml配置文件:
common: loglevel: info search_backend: "_env:SEARCH_BACKEND:"sqlalchemy_index_database:"_env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db"prod: loglevel: warn storage: s3 s3_access_key: _env:AWS_S3_ACCESS_KEY s3_secret_key: _env:AWS_S3_SECRET_KEY s3_bucket: _env:AWS_S3_BUCKET boto_bucket: _env:AWS_S3_BUCKET storage_path: /srv/docker smtp_host: localhost from_addr: docker@myself.com to_addr: my@myself.com dev: loglevel: debug storage: local storage_path: /home/myself/docker test: storage: local storage_path: /tmp/tmpdockertmpDocker Registry的默認運行環境是dev, 若是你須要更改運行環境, 可經過環境變量SETTINGS_FLAVOR來指定, 例如, 經過執行以下可設定運行環境爲prod.
export SETTINGS_FLAVOR=prod
Docker Registry運行時能夠經過環境變量DOCKER_REGISTRY_CONFIG指定config.yml的默認路徑, 例如指定config.yml的默認位置爲/opt/docker-registry/conf以下:
export DOCKER_REGISTRY_CONFIG=/opt/docker-registy/conf/config.yml
配置選項
通用配置選項包括loglevel, debug_versions, storage_redirect等, 其中logleve能夠設置爲info, debug, warn, error和critical級別.
# 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.
# 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.
# 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.
local: storage: file storage_path: /mnt/registry prod: storage: s3 s3_region: us-west-1 s3_bucket: acme-docker storage_path: /registry s3_access_key: AKIAHSHB43HS3J92MXZ s3_secret_key: xdDowwlK7TJajV1Y7EoOZrmuPEJlHYcNP2k4j49T
準備Docker Registry的配置文件路徑以及在dev, test, prod模式下存放p_w_picpaths的路徑.
mkdir -p /opt/docker-registry/{conf,dev,test,prod}
配置config.yml文件以下:
# All other flavors inherit the `common' config snippetcommon: &common# Default log level is info loglevel: _env:LOGLEVEL:info# Enable the debugging /_versions endpoint debug_versions: _env:DEBUG_VERSIONS:false# 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.io index_endpoint: _env:INDEX_ENDPOINT:https://index.docker.io# Storage redirect is disabled storage_redirect: _env:STORAGE_REDIRECT# Token auth is enabled (if NOT standalone) disable_token_auth: _env:DISABLE_TOKEN_AUTH# No priv key privileged_key: _env:PRIVILEGED_KEY# No search backend search_backend: _env:SEARCH_BACKEND# SQLite search backend sqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db# Enable bugsnag (set the API key) bugsnag: _env:BUGSNAG local: &local<<: *common storage: local# This is the default configuration when no flavor is specifieddev: &dev<<: *local loglevel: _env:LOGLEVEL:debug debug_versions: _env:DEBUG_VERSIONS:true search_backend: _env:SEARCH_BACKEND:sqlalchemy storage_path: _env:STORAGE_PATH:/opt/docker-registry/dev# This flavor is used by unit teststest:<<: *dev standalone: true storage_path: _env:STORAGE_PATH:/opt/docker-registry/test# To specify another flavor, set the environment variable SETTINGS_FLAVOR# $ export SETTINGS_FLAVOR=prodprod:<<: *dev storage_path: _env:STORAGE_PATH:/opt/docker-registry/prod
運行Docker Registry(dev模式)
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爲配置文件, 最後運行輸出以下:
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上傳p_w_picpath:
docker tag busybox 10.224.106.43:5000/busybox [root@golang dev]# docker push 10.224.106.43:5000/busyboxThe push refers to a repository [10.224.106.43:5000/busybox] (len: 1) Sending p_w_picpath list Pushing repository 10.224.106.43:5000/busybox (1 tags) 511136ea3c5a: Image successfully pushed 42eed7f1bf2a: Image successfully pushed 120e218dd395: Image successfully pushed a9eb17255234: Image successfully pushed Pushing tag for rev [a9eb17255234] on {http://10.224.106.43:5000/v1/repositories/busybox/tags/latest}與此同時, 你能在Docker Registry container運行的終端看到上傳busybox的日誌記錄, 如:
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 = {'p_w_picpath_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/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_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/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_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/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}10.224.106.43 - - [16/Sep/2014:15:07:54] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_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/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpath_id': u'a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/p_w_picpaths/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/p_w_picpaths/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 = {'p_w_picpaths': True, 'namespace': 'library', 'repository': u'busybox'}10.224.106.43 - - [16/Sep/2014:15:07:55] "PUT /v1/repositories/busybox/p_w_picpaths 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/p_w_picpaths 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目錄下, 你能看到兩個新的目錄p_w_picpaths和repositories, 這是新上傳busybox的信息. 並且你能夠在其餘機器上從Docker Registry(10.224.106.43)上下載剛上傳的p_w_picpath. 如:
[root@docker02 ~]# docker pull 10.224.106.43:5000/busyboxPulling repository 10.224.106.43:5000/busybox a9eb17255234: Download complete 511136ea3c5a: Download complete 42eed7f1bf2a: Download complete 120e218dd395: Download complete
運行Docker Registry(prod模式)
經過環境變量
SETTINGS_FLAVOR使得Docker Registry以prod模式運行, 運行命令如:
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這時若是上傳p_w_picpath,你能在/opt/docker-registry/prod下發現新上傳的p_w_picpath數據, 並且也能夠從其餘機器下載新上傳的p_w_picpath.
[root@golang conf]# docker push 10.224.106.43:5000/busyboxThe push refers to a repository [10.224.106.43:5000/busybox] (len: 1) Sending p_w_picpath list Pushing repository 10.224.106.43:5000/busybox (1 tags) 511136ea3c5a: Image successfully pushed 42eed7f1bf2a: Image successfully pushed 120e218dd395: Image successfully pushed a9eb17255234: Image successfully pushed Pushing tag for rev [a9eb17255234] on {http://10.224.106.43:5000/v1/repositories/busybox/tags/latest} [root@golang prod]# pwd/opt/docker-registry/prod [root@golang prod]# lltotal 4drwxr-xr-x. 6 root root 4096 Sep 16 11:36 p_w_picpaths drwxr-xr-x. 3 root root 20 Sep 16 11:36 repositories [root@docker02 ~]# docker pull 10.224.106.43:5000/busyboxPulling repository 10.224.106.43:5000/busybox a9eb17255234: Download complete 511136ea3c5a: Download complete 42eed7f1bf2a: Download complete 120e218dd395: Download complete