クラウドクラウドを使用したGoogleクラウドへのDocker画像の配備
5181 ワード
In this article, I would like to document how I deploy a Docker image to Google Cloud using Cloud Run.
目次
ビルドのイメージ
記事を参照Dockerizing a Node.js web application ノードの展開.JSアプリケーションと建物のイメージを構築する.
クラウドの設定
Googleクラウドプロジェクト
既にプロジェクトを作成している場合は、このセクションをスキップすることができますConfigure a Google Cloud Project .
Googleクラウドシェルでは、次の手順を実行します.
アカウントのアカウントを一覧表示し、希望のアカウントがアクティブに設定されていることを確認します.
gcloud auth list
プロジェクトを作成します.
gcloud projects create PROJECT_ID
* *Replace PROJECT_ID with your desired project ID.*
クラウドの設定
プロジェクト一覧.
gcloud projects list
デフォルトのプロジェクトを設定します.
gcloud config set project PROJECT_ID
* *Replace PROJECT_ID with your project ID.*
プロジェクトIDを出力します.
echo $GOOGLE_CLOUD_PROJECT
デフォルトを設定するzone 設定されていない場合:
gcloud config set compute/zone COMPUTE_ZONE
* *Replace COMPUTE_ZONE with your compute zone, such as europe-west2-c.*
デフォルトを設定するregion 設定されていない場合:
gcloud config set compute/region COMPUTE_REGION
* *Replace COMPUTE_REGION with your compute region, such as europe-west2.*
設定を表示します.
gcloud config list
GoogleクラウドシェルでAPIを有効にします.
クラウドを有効にする.
run.googleapis.com
クラウドに配備
展開
コンテナレジストリにDockerイメージを提出します.
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/website
* *Replace PROJECT_ID with your project ID.*
Docker画像が正常に提出されたことを確認するには、このプロジェクトのすべてのコンテナイメージを一覧表示します.
gcloud container images list
コンテナイメージをクラウドに展開します.
gcloud run deploy CONTAINER_NAME \
--image gcr.io/$GOOGLE_CLOUD_PROJECT/DOCKER_IMAGE_NAME:DOCKER_IMAGE_VERSION \
--platform managed \
--region GCR_REGION \
--allow-unauthenticated
* *Replace CONTAINER_NAME with the desired Container Name.*
* *Replace DOCKER_IMAGE_NAME with your docker image name.*
* *Replace DOCKER_IMAGE_VERSION with the version of your docker image name.*
* *Replace PROJECT_ID with your project ID.*
* *Replace GCR_REGION with your region, such as europe-west2.*
以下に作業例を示します.```shell
gcloud run deploy portfolio-website \
--image gcr.io/$GOOGLE_CLOUD_PROJECT/website:latest \
--platform managed \
--region europe-west1 \
--allow-unauthenticated
```
検証
参考文献
Reference
この問題について(クラウドクラウドを使用したGoogleクラウドへのDocker画像の配備), 我々は、より多くの情報をここで見つけました https://dev.to/adafycheng/deploy-a-docker-image-to-google-cloud-using-cloud-run-3oh0テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol