接下來部署雲端會使用GCP,今天先介紹GCP上的私有docker庫
可以先建個project
安裝SDK,以ubuntu為例
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
gcloud init
接著會出現要你登入google帳戶,登入後會出現
You are logged in as: [your_email@gmail.com].
Pick cloud project to use:
[1] it-test-project-288025
[2] othert-project-198613
[3] Create a new project
選一個工作的project
之後可以用
gcloud projects list
列出所有project,然後輸入
gcloud config set project your-project
來更改工作用的project
選完後會出現時區設定
Do you want to configure a default Compute Region and Zone? (Y/n)? y
Which Google Compute Engine zone would you like to use as project
default?
If you do not specify a zone via a command line flag while working
with Compute Engine resources, the default is assumed.
[26] asia-east1-b
[27] asia-east1-a
[28] asia-east1-c
asia-east1都在台灣,選一個就可以了
接著啟動權限
gcloud auth configure-docker
之後就能push與pull
docker push asia.gcr.io/[PROJECT-ID]/[your_image_name]:[your_tag]
docker pull asia.gcr.io/[PROJECT-ID]/[your_image_name]:[your_tag]
在台灣記得是asia.gcr.io,這是亞洲區的server
現在可以看到我們的image了
可以在這邊設置為私有庫或公開