Google Container Registry(GCR)是GCP提供以Google Cloud Storage為儲存空間的Docker Registry,可以透過GCP的Cloud Storage空間來存放Image。
gcloud auth configure-docker
docker build -t [HOSTNAME]/[PROJECT-ID]/[IMAGE] -f [DOCKERFILE_PATH] .
HOSTNAME: 映像檔的存儲位置
- gcr.io 美國
- us.gcr.io 美國
- eu.gcr.io 歐洲
- asia.gcr.io 亞洲
docker tag [SOURCE_IMAGE]:[TAG] [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG]
➜ ~ docker tag myproject:v1.0.1 gcr.io/xxxxx/myproject:v1.0.1
➜ ~ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
myproject v1.0.1 dc3608e3892f 7 days ago 364MB
gcr.io/xxxxxx/myproject v1.0.1 dc3608e3892f 7 days ago 364MB
docker push [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG]
上傳映像檔成功後如下
➜ ~ docker push gcr.io/xxxxxx/myproject:v1.0.1
The push refers to repository [gcr.io/xxx-xxx/myproject]
1b92afa0c55e: Pushed
1b894eedb7e7: Pushed
e471cf366f0e: Pushed
f20725574379: Layer already exists
6890d0d60111: Layer already exists
1ba1431fe2ba: Layer already exists
0f7493e3a35b: Layer already exists
50644c29ef5a: Layer already exists
v1.0.1: digest: sha256:8d2f74e22f23e7bbaef55911bb1d9d618678c60fcf89c3174264b85a5c98fad8 size: 1995