Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Google Compute Engine not running my container?

I can do this successfully:

  • Bundle my app into a docker image
  • Build this image into a container using Google Cloud Build upon push to master
    • (This container is stored in the registry at, for example, gcr.io/my-project/my-container)
  • Deply this container to the web using Google Cloud Run
  • Visit the Cloud Run url and see my website

I am now trying more sophisticated builds and I think the next step is to use Google Compute Engine.

To start, I am simply trying to deploy a single instance of the same app that I deployed to Cloud Run:

  • Navigate to Compute Engine > VM Instances
  • Enter basics like instance name
  • Enter my container location under "Container Image": gcr.io/my-project/my-container
    • (As an aside, I find it suspect that the interface does not offer a selector for your existing Container Registry items here.)
  • Select "Allow HTTP Traffic" and "Allow HTTPS Traffic"
  • Click "Create"

GCE takes a minute to create it, and then it shows the green checkmark and the instance name, and "External IP: 35.238.xxx.xxx". I visit that URL in my browser and get... "35.238.xxx.xxx refused to connect."

To inspect, I go back to the GCE page and select "SSH > Open in browser window" next to my instance, which opens a type of cloud terminal to the machine.

In this terminal window, type ps and see that no processes are running. The container Dockerfile ends with CMD yarn start:prod, so I guess that's not happening here.

Further, I ls here and there and navigate around, and see that there is no /app directory from my Dockerfile's WORKDIR /app command. It seems like not only did my app not boot, but was the container not copied to the VM instance?

What am I doing wrong?

like image 756
cilphex Avatar asked Apr 01 '20 07:04

cilphex


1 Answers

For anyone having this issue. I faced the same problem and couldn't figure it out.

Reading Serhii's answer give me the clue. I believe as of today (Jan 2021) the GCP Console UI is a bit unhelpful. It appears that if you type in a container name when creating your VM but WITHOUT specifying a tag on the end, it doesn't complain nor assume a default such as 'latest', it just fails silently. Hence the VM but with no docker container running.

At least it this now works for me, hopefully this helps others.

like image 121
Spanners Avatar answered Oct 11 '22 15:10

Spanners