{"id":164,"date":"2020-11-07T22:07:00","date_gmt":"2020-11-07T13:07:00","guid":{"rendered":"http:\/\/localhost:8000\/?p=164"},"modified":"2021-01-16T14:16:22","modified_gmt":"2021-01-16T05:16:22","slug":"gcr","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2020\/11\/gcr.html","title":{"rendered":"GCR\uff08Google Container Registry\uff09\u3092\u4f7f\u3063\u3066\u307f\u308b"},"content":{"rendered":"
Google Container Registry\uff08GCR\uff09<\/a>\u306fGCP\u304c\u63d0\u4f9b\u3059\u308b\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u306aDocker Registry\u3067\u3059\u3002Docker Hub<\/a>\u3068\u540c\u3058\u3088\u3046\u306bDocker\u30a4\u30e1\u30fc\u30b8\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\/\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u3067\u304d\u3001\u304b\u3064\u3001\u5916\u90e8\u304b\u3089\u5229\u7528\u3055\u308c\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n \u4eca\u56de\u306f\u3001\u81ea\u4f5c\u3057\u305fDocker\u30a4\u30e1\u30fc\u30b8\u3092\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u901a\u3058\u3066CLI\u3067GCR\u306bpush\u3057\u3066pull\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3092\u691c\u8a3c\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u57fa\u672c\u7684\u306b\u306f\u516c\u5f0f\u306e\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8<\/a>\u3092\u30d9\u30fc\u30b9\u306b\u691c\u8a3c\u3092\u9032\u3081\u307e\u3059\u3002<\/p>\n \u4ee5\u4e0b\u306e\u69d8\u306a\u3053\u3068\u304c\u3067\u304d\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n \u4eca\u56de\u306f\u3053\u308c\u306e\u3046\u30611.\u30682.\u3042\u305f\u308a\u3092\u8efd\u304f\u691c\u8a3c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n \u30a4\u30e1\u30fc\u30b8\u3092 \u30ed\u30b0\u3092\u898b\u308b\u9650\u308a\u3001\u4ee5\u4e0b\u306e\uff12\u70b9\u3092\u3084\u3063\u3066\u304f\u308c\u3066\u3044\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n Dockerfile\u3092\u4f5c\u6210\u3057\u307e\u3059<\/p>\n Docker\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n \u3055\u3089\u306b\u3001DCR\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u305f\u3081\u306b\u3001GCR\u306e\u547d\u540d\u898f\u5247<\/a>\u306b\u5408\u308f\u305b\u3066\u30bf\u30b0\u3092\u3064\u3051\u76f4\u3057\u307e\u3059\u3002<\/p>\n \u6700\u521d\u304b\u3089Docker\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b\u969b\u306bGCR\u306e\u547d\u540d\u898f\u5247\u3067\u30bf\u30b0\u4ed8\u3051\u3059\u308b\u65b9\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n \u3042\u3068\u306f \u30b3\u30f3\u30bd\u30fc\u30eb<\/a> \u304b\u3089\u78ba\u8a8d\u3059\u308b\u3068\u7121\u4e8bDocker\u30a4\u30e1\u30fc\u30b8\u304cGCR\u4e0a\u306bpush\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n <\/p>\n \u53f3\u5074\u306e\u64cd\u4f5c\u30d7\u30eb\u30c0\u30a6\u30f3\u304b\u3089\u30a4\u30e1\u30fc\u30b8\u306e\u524a\u9664\u3092\u542b\u3081\u3044\u304f\u3064\u304b\u306e\u64cd\u4f5c\u3067\u304d\u308b\u69d8\u3067\u3059\u3002<\/p>\n \u3053\u3061\u3089\u3082 \u5b9f\u969b\u306e\u904b\u7528\u3067\u306f\u500b\u4eba\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u4f5c\u696d\u3059\u308b\u3053\u3068\u306f\u5c11\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u3082 \u3053\u3061\u3089<\/a>\u304b\u3089\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n \u6b21\u306b\u3001\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u6709\u52b9\u5316\u3057\u307e\u3059\u3002<\/p>\n \u307e\u305a\u306f \u5c11\u3057\u95a2\u9023\u3057\u3066\u3001Airflow\u306eDockerOperator\u3067GCR\u304b\u3089\u30a4\u30e1\u30fc\u30b8\u3092pull\u3059\u308b\u4ef6\u3082\u4ee5\u4e0b\u306e\u8a18\u4e8b\u306e\u4e2d\u3067\u691c\u8a3c\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u3054\u53c2\u8003\u307e\u3067\u3002 \u308f\u3056\u308f\u3056\u8a18\u4e8b\u8d77\u3053\u3059\u307b\u3069\u3082\u306a\u3044\u3050\u3089\u3044\u7279\u306b\u30cf\u30de\u308b\u3053\u3068\u3082\u306a\u304f\u30b5\u30af\u30c3\u3068\u52d5\u304d\u307e\u3057\u305f\u3002\u666e\u6bb5\u304b\u3089GCP\u3092\u4f7f\u3063\u3066\u308b\u306e\u3067\u3001\u4eca\u5f8c\u306fDocker\u30a4\u30e1\u30fc\u30b8\u306f\u3053\u3053\u3067\u7ba1\u7406\u3057\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" Google Container Registry\uff08GCR\uff09\u306fGCP\u304c\u63d0\u4f9b\u3059\u308b\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u306aDocker Registry\u3067\u3059\u3002Docker Hub\u3068\u540c\u3058\u3088\u3046\u306bDocker\u30a4\u30e1\u30fc\u30b8\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\/\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u3067\u304d\u3001\u304b\u3064\u3001\u5916\u90e8\u304b\u3089\u5229\u7528\u3055\u308c\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u305b\u3093\u3002 \u4eca\u56de\u306f\u3001\u81ea\u4f5c\u3057\u305fDocker\u30a4\u30e1\u30fc\u30b8\u3092\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u901a\u3058\u3066CLI\u3067GCR\u306bpush\u3057\u3066pull\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3092\u691c\u8a3c\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u57fa\u672c\u7684\u306b\u306f\u516c\u5f0f\u306e\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8\u3092\u30d9\u30fc\u30b9\u306b\u691c\u8a3c\u3092\u9032\u3081\u307e\u3059\u3002 GCR\u306e\u7279\u5fb4 \u4ee5\u4e0b\u306e\u69d8\u306a\u3053\u3068\u304c\u3067\u304d\u308b\u307f\u305f\u3044\u3067\u3059\u3002 Docker Registory\u3068\u3057\u3066\u3001Docker\u30a4\u30e1\u30fc\u30b8\u3092push\u3057\u305f\u308apull\u3057\u305f\u308a\u3067\u304d\u308b \u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u304c\u3067\u304d\u308b CI\/CD\u30b7\u30b9\u30c6\u30e0\u3068\u9023\u52d5\u3067\u304d\u308b \u4eca\u56de\u306f\u3053\u308c\u306e\u3046\u30611.\u30682.\u3042\u305f\u308a\u3092\u8efd\u304f\u691c\u8a3c\u3057\u3066\u307f\u307e\u3059\u3002 \u4e8b\u524d\u6e96\u5099 GCP\u5074\u306e\u8a2d\u5b9a \u3053\u3061\u3089\u304b\u3089GCP\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\/\u9078\u629e\u3057\u307e\u3059 \u4eca\u56de <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/164"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=164"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":165,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/164\/revisions\/165"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}GCR\u306e\u7279\u5fb4<\/h2>\n
\n
\u4e8b\u524d\u6e96\u5099<\/h2>\n
GCP\u5074\u306e\u8a2d\u5b9a<\/h3>\n
\n
\n
cloud-registry-test<\/code>\u3068\u3044\u3046\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u65b0\u898f\u306b\u4f5c\u308a\u307e\u3057\u305f<\/li>\n<\/ul>\n<\/li>\n
\n
\n
\u30ed\u30fc\u30ab\u30ebPC\u5074\u306e\u8a2d\u5b9a<\/h3>\n
\n
\n
\n
docker run busybox date<\/code>\u3092terminal\u3067\u5b9f\u884c\u3057\u3066\u65e5\u6642\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n
\u8a8d\u8a3c\u3092\u69cb\u6210\u3059\u308b<\/h2>\n
docker push<\/code>\u307e\u305f\u306f
docker pull<\/code>\u3059\u308b\u5834\u5408\u3001\u5358\u7d14\u306bContainer Registory\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001gcloud CLI \u3092\u901a\u3058\u3066Container Registry \u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8a8d\u8a3c\u3059\u308b\u3088\u3046\u306b Docker \u3092\u69cb\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n
gcloud auth configure-docker\n\n> Adding credentials for all GCR repositories.\n> WARNING: A long list of credential helpers may cause delays running 'docker build'. We recommend passing the registry name to configure only the registry you are using.\n> After update, the following will be written to your Docker config file\n> located at [\/Users\/rinoguchi\/.docker\/config.json]:\n> {\n> "credHelpers": {\n> "gcr.io": "gcloud",\n> "us.gcr.io": "gcloud",\n> "eu.gcr.io": "gcloud",\n> "asia.gcr.io": "gcloud",\n> "staging-k8s.gcr.io": "gcloud",\n> "marketplace.gcr.io": "gcloud"\n> }\n> }\n> \n> Do you want to continue (Y\/n)? Y\n> \n> Docker configuration file updated.<\/code><\/pre>\n
\n
gcloud<\/code>\u3092\u30af\u30ec\u30c7\u30f3\u30b7\u30e3\u30eb\u30d8\u30eb\u30d1\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u3001\u3068\u3044\u3046\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b<\/li>\n<\/ul>\n
\u500b\u4eba\u30a2\u30ab\u30a6\u30f3\u30c8\u3067Docker\u30a4\u30e1\u30fc\u30b8\u3092GCR\u306bpush\/pull\u3059\u308b<\/h2>\n
\u500b\u4eba\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b<\/h3>\n
# \u30ed\u30b0\u30a4\u30f3\ngcloud auth loging xxxxx@gmail.com # => \u30d6\u30e9\u30a6\u30b6\u3067\u8a8d\u8a3c\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u305d\u3053\u3067\u8a8d\u8a3c\u3092\u884c\u3046\n\n# \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u8a2d\u5b9a\ngcloud config set project cloud-registry-test\n> Updated property [core\/project].\n\n# \u78ba\u8a8d\ngcloud config list\n> [core]\n> account = xxxxx@gmail.com\n> disable_usage_reporting = False\n> project = cloud-registry-test<\/code><\/pre>\n
Docker\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n
FROM python:latest\nENTRYPOINT [ "python", "-c", "print('python executed.')" ]<\/code><\/pre>\n
docker build -t python-sample:latest .\n\n> Sending build context to Docker daemon 2.048kB\n> Step 1\/2 : FROM python:latest\n> ---> 5336a27a9b1f\n> Step 2\/2 : ENTRYPOINT [ "python", "-c", "print('python executed.')" ]\n> ---> Using cache\n> ---> 097cd088e9a4\n> Successfully built 097cd088e9a4\n> Successfully tagged python-sample:latest<\/code><\/pre>\n
python-sample:latest<\/code>\u3068\u3044\u3046\u30bf\u30b0\u3067\u30ed\u30fc\u30ab\u30eb\u306eDocker Registry\u306bDocker\u30a4\u30e1\u30fc\u30b8\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n
docker tag python-sample:latest asia.gcr.io\/cloud-registry-test\/python-sample:latest<\/code><\/pre>\n
docker build -t asia.gcr.io\/cloud-registry-test\/python-sample:latest .<\/code><\/pre>\n
GCR\u306bpush\u3059\u308b<\/h3>\n
docker push<\/code>\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n
docker push asia.gcr.io\/cloud-registry-test\/python-sample:latest\n\n> The push refers to repository [asia.gcr.io\/cloud-registry-test\/python-sample]\n> 495sa1d6fa86e2: Layer already exists \n> \u7701\u7565\n> c4fc3hwbd6e3cb: Layer already exists \n> latest: digest: sha256:7vfq87vqreghjiqwef978vchdqwuirweokj2fed8becd235 size: 2217<\/code><\/pre>\n
GCR\u304b\u3089pull\u3059\u308b<\/h3>\n
docker pull<\/code>\u3067\u554f\u984c\u306a\u304f\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n
docker pull asia.gcr.io\/cloud-registry-test\/python-sample:latest\n\n> latest: Pulling from cloud-registry-test\/python-sample\n> Digest: sha256:7vfq87vqreghjiqwef978vchdqwuirweokj2fed8becd235\n> Status: Downloaded newer image for asia.gcr.io\/cloud-registry-test\/python-sample:latest\n> asia.gcr.io\/cloud-registry-test\/python-sample:latest<\/code><\/pre>\n
\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3067Docker\u30a4\u30e1\u30fc\u30b8\u3092GCR\u306bpush\/pull\u3059\u308b<\/h2>\n
docker push<\/code>\u304a\u3088\u3073
docker pull<\/code>\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n
\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n
\n
cloud-registry-test-account<\/code>\u3068\u3044\u3046\u540d\u524d\u3092\u3064\u3051\u307e\u3057\u305f\uff09<\/li>\n
\n
\n
\n
# \u6709\u52b9\u5316\ngcloud auth activate-service-account --key-file .\/cloud-registry-test-xxxxxxxxxx.json --project cloud-registry-test\n> Activated service account credentials for: [cloud-registry-test-account@cloud-registry-test.iam.gserviceaccount.com]\n\n# \u78ba\u8a8d\ngcloud config list\n> [core]\n> account = cloud-registry-test-account@cloud-registry-test.iam.gserviceaccount.com\n> disable_usage_reporting = False\n> project = cloud-registry-test<\/code><\/pre>\n
GCR\u306bpush\u3001GCR\u304b\u3089pull\u3059\u308b<\/h3>\n
docker push<\/code>\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u554f\u984c\u306a\u304f\u52d5\u304d\u307e\u3057\u305f\u3002<\/p>\n
docker push asia.gcr.io\/cloud-registry-test\/python-sample:latest\n> The push refers to repository [asia.gcr.io\/cloud-registry-test\/python-sample]\n> 4951d6fa86e2: Layer already exists \n> \u7701\u7565\n> latest: digest: sha256:7vfq87vqreghjiqwef978vchdqwuirweokj2fed8becd235 > size: 2217<\/code><\/pre>\n
docker pull<\/code>\u3082\u5927\u4e08\u592b\u3067\u3057\u305f\u3002<\/p>\n
docker pull asia.gcr.io\/cloud-registry-test\/python-sample:latest\n> latest: Pulling from cloud-registry-test\/python-sample\n> Digest: sha256:7vfq87vqreghjiqwef978vchdqwuirweokj2fed8becd235\n> Status: Image is up to date for asia.gcr.io\/cloud-registry-test\/python-sample:latest\n> asia.gcr.io\/cloud-registry-test\/python-sample:latest<\/code><\/pre>\n
\u305d\u306e\u4ed6<\/h2>\n
\nAirflow\u3067DockerOperator\u3092\u52d5\u304b\u3059<\/a><\/p>\n\u3055\u3044\u3054\u306b<\/h2>\n