2

我正在尝试在 Google Container Engine 中运行 docker 映像。该实例没有运行 docker 镜像。我可以 ssh 并运行 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
4

1 回答 1

1

您在问题中提到您正在使用谷歌容器引擎,但实际上您正在使用容器 vm(这有点不同)。如果您想使用容器引擎,请查看文档以创建容器集群

我运行了您的示例,并/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 的文档已经过时了。

于 2015-05-19T17:34:28.450 回答