使用gcr.io

Google Container Registry(gcr.io)所提供的服務內容為以Google Cloud Storage為儲存空間的Docker Registry方案,透過gcr.io這個服務器位置提供每個專案的Cloud Storage空間來放置Container Image...

找出要存放的Container

使用registry之前,首先需要知道欲存放的container id,透過docker ps可以列出目前running中的registry跟相關資訊:

root@paltform-services:~# docker ps
CONTAINER ID        IMAGE                                                   COMMAND               CREATED             STATUS              PORTS                                                                                            NAMES
5a5f1b0092f2        google/cadvisor:latest                                  "/usr/bin/cadvisor"   4 days ago          Up 4 days                                                                                                            k8s--cadvisor.1207d44b--cadvisor_-_agent.file--85db4c22                                                                                                                                            
f95a52adfbbb        kubernetes/pause:latest                                 "/pause"              5 days ago          Up 5 days           0.0.0.0:4194->8080/tcp                                                                           k8s--net.46426d55--cadvisor_-_agent.file--57627618                                                                                                                                                 
9da467654712        c42f8365a6ec                                            "bash"                2 weeks ago         Up 4 days           0.0.0.0:5984->5984/tcp                                                                           couchdb12,drunk_goldstine/couchdb12,evil_almeida/couchdb12,kickass_meitner/couchdb12,naughty_blackwell/couchdb12,nostalgic_davinci/couchdb12,prickly_torvalds/couchdb12,romantic_kirch/couchdb12

本地端儲存docker image

然後針對需要存放的image先做一個本地端的commit,讓本地端image先固定一個版本下來...

root@paltform-services:~# docker commit -m "commit 20150126" -a "simonsu" 9da467654712 couchdb12
b7632ab16d0b92467382cd909b4608da9b2d16fe0994c891c723194947c864d9

替image製作tag

接著對該image做一個tag,且tag的名稱必須要以gcr.io開頭,中間為專案名稱(需要把"-"轉為"_"),最後為要存放的Image名稱...,名稱規則如下:

docker tag [image-name] gcr.io/[project-id-using-underscore]/[repository-image-name]

執行範例如下:

root@paltform-services:~# docker tag couchdb12 gcr.io/inbound_trilogy_601/couchdb12

Commit到Google Container Registry

最後的動作就是commit到專案所附屬的registry(gcr),這邊需要透過先前安裝的gcloud preview指令...

root@paltform-services:~# gcloud preview docker push gcr.io/inbound_trilogy_601/couchdb12
The push refers to a repository [gcr.io/inbound_trilogy_601/couchdb12] (len: 1)
Sending image list
Pushing repository gcr.io/inbound_trilogy_601/couchdb12 (1 tags)
Image 511136ea3c5a already pushed, skipping
Image 1aeada447715 already pushed, skipping
Image 479215127fa7 already pushed, skipping
Image c42f8365a6ec already pushed, skipping
b7632ab16d0b: Image successfully pushed 
Pushing tag for rev [b7632ab16d0b] on {https://gcr.io/v1/repositories/inbound_trilogy_601/couchdb12/tags/latest}
root@paltform-services:~#

Cloud Storage的變化

當registry有存放東西後,在Google Cloud Storage上會以該專案的名稱組合產生一個bucket,名稱類似這樣:

artifacts.[project-id].appspot.com

從browser觀看,大致上有如下目錄:

gcr storage

Reference: https://cloud.google.com/tools/container-registry/

results matching ""

    No results matching ""