如何在 Google Container Engine 上运行私有 docker 镜像 [英] How do I run private docker images on Google Container Engine
问题描述
如何运行我在 Google 容器引擎上本地构建的 docker 映像?
How do I run a docker image that I built locally on Google Container Engine?
推荐答案
您可以将您的图片推送到 Google Container Registry 并从您的 pod 清单中引用它们.
You can push your image to Google Container Registry and reference them from your pod manifest.
假设您正确设置了 DOCKER_HOST
、运行最新版本 Kubernetes 的 GKE 集群和 已安装 Google Cloud SDK.
Assuming you have a DOCKER_HOST
properly setup , a GKE cluster running the last version of Kubernetes and Google Cloud SDK installed.
设置一些环境变量
Setup some environment variables
gcloud components update kubectl
gcloud config set project <your-project>
gcloud config set compute/zone <your-cluster-zone>
gcloud config set container/cluster <your-cluster-name>
gcloud container clusters get-credentials <your-cluster-name>
标记您的图片
Tag your image
docker tag <your-image> gcr.io/<your-project>/<your-image>
推送你的图片
Push your image
gcloud docker push gcr.io/<your-project>/<your-image>
为您的容器创建一个 pod 清单:my-pod.yaml
id: my-pod
kind: Pod
apiVersion: v1
desiredState:
manifest:
containers:
- name: <container-name>
image: gcr.io/<your-project>/<your-image>
...
安排此 Pod
Schedule this pod
kubectl create -f my-pod.yaml
从第 (4) 步开始对您要运行的每个 Pod 重复.您可以使用带有 ---
作为分隔符的行在单个文件中包含多个定义.
Repeat from step (4) for each pod you want to run. You can have multiple definitions in a single file using a line with ---
as delimiter.
这篇关于如何在 Google Container Engine 上运行私有 docker 镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!