STEP1: 建立registry的環境檔案

echo "GCP_OAUTH2_REFRESH_TOKEN=`gcloud auth print-refresh-token`" > registry-params.env
echo "GCS_BUCKET=simon-docker" > registry-params.env

STEP2: 進到boot2docker pull registry

$ boot2docker ssh
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
boot2docker: 1.2.0
             3.16.1-config-file : e75396e - Fri Aug 22 06:45:30 UTC 2014
[email protected]:~$ docker pull google/docker-registry

這邊需要在boot2docker中pull的原因是,在外部pull時候,的原因是從外部pull,一直收到一個錯誤資訊:

$ docker run -d --env-file=registry-params.env -p 5000:5000 google/docker-registry
Unable to find image 'google/docker-registry' locally
Pulling repository google/docker-registry
2015/01/09 23:00:37 Authentication is required.

而,欲使用一般的docker interactive terminal的方式謢行,可以看到一些資訊

$ docker run -d -e GCS_BUCKET=simon-docker -p 5000:5000 google/docker-registry
grep: /.config/gcloud/properties: No such file or directory
find: `/.config/gcloud/legacy_credentials//.boto': No such file or directory
Boto credentials not found.  Either:
 - Set GCP_OAUTH2_REFRESH_TOKEN
 - Set BOTO_PATH
 - Mount gcloud credentials under /.config in the container and optionally set GCP_ACCOUNT
 - Run in GCE with a service account configured for devstorage access

docker run -e GCS_BUCKET=<YOUR_GCS_BUCKET_NAME> [-e GCP_ACCOUNT='<YOUR_EMAIL>' ] [-e BOTO_PATH='/.config/gcloud/legacy_credentials/<YOUR_EMAIL>/.boto'] [-e GCP_OAUTH2_REFRESH_TOKEN=<refresh token>] -p 5000:5000 [--volumes-from gcloud-config] google/docker-registry

原因是boot2docker執行當下,的環境是跳到VirtualBox中去執行,但gcloud的認證卻是在Mac的Shell中執行的,因此實際執行docker時,docker即無法抓取已經認證過的環境... 這也是在這邊需要採用STEP1的認證方式的原因...

STEP3: 當pull完成後,退回到Mac console下,再執行registry指令

docker run -d --env-file=registry-params.env -p 5000:5000 google/docker-registry

檢查後,可以發現Process已經有起來

docker ps
CONTAINER ID        IMAGE                           COMMAND             CREATED             STATUS              PORTS                    NAMES
e28d6b6e9561        google/docker-registry:latest   "./run.sh"          28 hours ago        Up 2 seconds        0.0.0.0:5000->5000/tcp   trusting_hopper

results matching ""

    No results matching ""