gpt4 book ai didi

kubernetes - 如何在Google容器引擎上运行docker镜像?

转载 作者:行者123 更新时间:2023-12-02 11:46:17 24 4
gpt4 key购买 nike

我正在尝试在Google Container Engine中运行docker镜像。该实例没有运行的docker镜像。我可以ssh并运行docker命令,该服务就会启动。但是,当我从终端启动实例时,什么也没有发生。有人可以看看我在做什么错。

我的docker文件看起来像

FROM golang
RUN mkdir -p /app
COPY . /app
RUN go get golang.org/x/tools/cmd/present
ENTRYPOINT cd /app && /go/bin/present -http=":8080"
EXPOSE 8080

container.yaml看起来像
version: v1beta3
containers:
- name: talks
image: sheki/talks
ports:
- name: http-port
containerPort: 8080
hostPort: 80'

启动实例的命令是
gcloud compute instances create zoop \
--image container-vm \
--metadata-from-file google-container-manifest=containers.yaml \
--zone us-central1-a \
--machine-type f1-micro

最佳答案

您在问题中提到您使用的是Google容器引擎,但实际上您使用的是container vm(有点不同)。如果要使用容器引擎,请查阅文档以创建container cluster

我运行了您的示例,在/var/log/kubelet.log中看到以下错误:

E0519 17:05:41.285556    2414 http.go:54] Failed to read URL: http://metadata.google.internal/computeMetadata/v1beta1/instance/attributes/google-cont
ainer-manifest: received 'version: v1beta3
containers:
- name: talks
image: sheki/talks
ports:
- name: http-port
containerPort: 8080
hostPort: 80'
', but couldn't parse as neither single (error unmarshaling JSON: json: cannot unmarshal string into Go value of type int: {Version:v1beta3 ID: UUID:
Volumes:[] Containers:[{Name:talks Image:sheki/talks Entrypoint:[] Command:[] WorkingDir: Ports:[{Name:http-port HostPort:0 ContainerPort:8080 Proto
col: HostIP:}] Env:[] Resources:{Limits:map[] Requests:map[]} CPU:0 Memory:0 VolumeMounts:[] LivenessProbe:<nil> ReadinessProbe:<nil> Lifecycle:<nil>
TerminationMessagePath: Privileged:false ImagePullPolicy: Capabilities:{Add:[] Drop:[]}}] RestartPolicy:{Always:<nil> OnFailure:<nil> Never:<nil>} D
NSPolicy: HostNetwork:false}) or multiple manifests (error unmarshaling JSON: json: cannot unmarshal object into Go value of type []v1beta1.Container
Manifest: []) nor single (kind not set in '{"containers":[{"image":"sheki/talks","name":"talks","ports":[{"containerPort":8080,"hostPort":"80'","name
":"http-port"}]}],"version":"v1beta3"}') or multiple pods (kind not set in '{"containers":[{"image":"sheki/talks","name":"talks","ports":[{"container
Port":8080,"hostPort":"80'","name":"http-port"}]}],"version":"v1beta3"}').

容器vms的文档似乎已过时。

关于kubernetes - 如何在Google容器引擎上运行docker镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30286853/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com