Search code examples
google-cloud-platformnetworkingvirtual-machinemetabase

How to access my GCP VM on localhost:3000


I have Metabase running through a Docker image on a Google Compute Engine. The application defaults to port localhost:3000 however, I can't seem to figure out how to access this port on the Google VM.

I tried accessing the VM through gcloud compute ssh {VM-NAME} --project={PROJECT} --zone={ZONE} and this works. I used the --troubleshoot option as well (no problems) and setup Firewall rules to make the VM accessible on TCP ports 22 and 3000

Note: I am a starting Data Engineer and just start to grasps the different concepts surrounding cloud computing, storage & networking. I think the problem must be somewhere surrounding the way I try to reach the Virtual Machine, however, I am unsure of where the problem lies exactly and I can't seem to find the solution online. I hope someone here can help me in the right direction so I can continue my learning journey!


Solution

  • There is many steps to check to achieve what you want to achieve:

    • Is the port 3000 accessible directly from the VM?
      • If not, it's because you did not forward the container port to the VM port. For that, you can perform docker run -p <containerPort>:<VMPort> ..., here use -p 3000:3000 for instance
    • If the port is accessible from the VM, be sure that the VM is publicly accessible (public IP).
      • If not, add an ephemeral public IP on your VM. Or more complex and expensive (but more secure) add a TCP load balancer in front of it.
    • Be sure your firewall rules are in place.