Google Cloud - Deploy as Container from GCR - Ports not exposed in docker container

3/19/2018

I have created a GCP VM instance, with option Deploy as Container pointing to an image in my private GCR(nginx customized).

Also while creating the instance, I had given allow 'https' and 'http' traffic.

Though the application is working fine, on connecting the instance via ssh and inspecting docker containers (docker ps) I see the container ports are not exposed. Wondering how the http/https request are handled by the container here via the instance??

-- Chet
docker
google-cloud-platform
google-compute-engine
google-container-os
google-kubernetes-engine

2 Answers

5/26/2018

Other than what @Stefan R has told, you should also use PORT number greater than 1000 as auto deployed container images aren't run as root and hence can't access privileged ports.

https://www.staldal.nu/tech/2007/10/31/why-can-only-root-listen-to-ports-below-1024/

https://www.google.co.in/search?q=privileged+ports+linux&oq=privileged+ports+linux

-- Ravinder Payal
Source: StackOverflow

3/19/2018

When you use the deploying containers option in GCE it runs docker with access to the host network.

From the relevant gcp docs :

Containerized VMs launch containers with the network set to host mode. A container shares the host network stack, and all interfaces from the host are available to the container.

More detailed info on the different network modes here.

-- Stefan R
Source: StackOverflow