无法将端口绑定到Google容器优化虚拟机中的容器

我正尝试在GCE的Google容器优化虚拟机上运行Docker容器。

这是我的dockerfile。 我build立了一个容器图像,并将其推送到gcr.io。

FROM nginx:1.9 COPY config /etc/nginx 

我写了一个容器清单文件。

 version: v1beta2 containers: - name: test image: gcr.io/myproject/test ports: - name: http hostPort: 80 containerPort: 80 - name: https hostPort: 443 containerPort: 443 

我用清单文件部署到GCE,但端口绑定不是我所期望的。 为什么主机端口80和443redirect到google_containers /暂停而不是myproject / test?

 local$ gcloud compute instance create test \ --image container-vm \ --metadata-from-file google-container-manifest=container.yaml \ --zone us-central1-b \ --machine-type f1-micro \ --tags http-server,https-server local$ gcloud compute ssh --zone us-central1-b test test$ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 818828ccc2c6 gcr.io/myproject/test:latest "nginx -g 'daemon of 23 seconds ago Up 22 seconds k8s_test.9de3822_7f9f8ecace94a22b2bea59ee14f3bcd0-test_df40d10c4dfa4 f40d10c4dfa4 gcr.io/google_containers/pause:0.8.0 "/pause" 32 seconds ago Up 31 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp k8s_POD.c6ce2a78_7f9f8ecace94a22b2bea59ee14f3bcd0-test_default_7f9f8ecace94a22b2bea59ee14f3bcd0-test_64d51838 

我已经更新版本的v1beta2 v1(v1beta3),并再次尝试。 端口绑定的结果看起来和前面的一样,但是容器可以通过端口80和443与外部networking进行通信。

 version:1 kind: Pod spec: restartPolicy: Always dnsPolicy: Default containers: - name: test image: gcr.io/myproject/test imagePullPolicy: Always ports: - name: http hostPort: 80 containerPort: 80 protocol: TCP - name: https hostPort: 443 containerPort: 443 protocol: TCP