【GCP 教學文】三分鐘在 GCE 上部署 Container

GCP 部署 Container 教學 - 建立

test
  • 勾選 Container ,此時會更換 Boot Disk 為 Container-Optimized OS

  • 設定 Container Image,如果並非公開 Image,而是自行打包的 Image,可以 push 至 GCS 上或使用 Google Cloud Container Builder(兩者皆需安裝 Google Cloud SDK)

自行打包

$ docker build -t ///: -f ./Dockerfile .

#ex
$ docker build -t us.gcr.io/hello-gcp/hello-gcp/myapp:0.1.13b -f ./Dockerfile .


其中 gcr.io 可依專案 region 切換

  • us.gcr.io hosts your images in the United States
  • eu.gcr.io hosts your images in the European Union
  • asia.gcr.io hosts your images in Asia
  • gcr.io without a prefix hosts your images in the United States, but this behavior may change in a future release

Push

$ gcloud docker -- push ///:

#ex
$ gcloud docker -- push us.gcr.io/hello-gcp/hello-gcp/myapp:0.1.13b

Cloud Container Builder

$ gcloud container builds submit -t

#ex
$ gcloud container builds submit -t us.gcr.io/hello-gcp/hello-gcp/myapp:0.1.13b .



GCP 部署 Container 教學 - 設定

test
  • 請依需求修改紅框

  • 如果有 –privileged, –cap-add 或 –cap-drop 需求請勾選 Run as privileged

  • 完成後啟動

GCP 部署 Container 教學 - Tips

  • 在上面執行的 Container 與 Host OS port 是一對一 mapping ,不需要額外設定

  • 如果對外服務請自行設定 VPC network Firewall rules

  • 可以對此 instance 進行 SSH 連線,連線後為 Host OS

  • 連線後可用 Docker 指令

  • 目前沒辦法用 Docker logs ,可用 Docker attach container-id相關文章

Contact CloudMile

Contact Us

Proven Experience Across Diverse Industries

Phone Number

  • TW+886
  • TW+886
  • Reason for Inquiry

  • Electrum Advisory

  • MileInfra - Cloud Infrastructure Modernization

  • Enterprise Technical Training

  • MileSec - Multi-Cloud Security and Operations

  • MileData - Cloud Data Management and Automation

  • MileOps - Hybrid and Multi-Cloud Operations

  • MileAI - Generative AI Applications and Innovation

  • LumiTure.ai AI-Powered FinOps Platform

  • Other

  • 請填寫電子信箱