1

I need to run a docker container when a Cloud function is triggered. Also, I need this Docker to mount a folder from an NFS file server VM that is running in a Google Cloud Compute Engine.

  • How can I run a docker container from a Firebase/Cloud Function?

  • If it is not possible, can I trigger a docker container hosted in Kubernetes from one of these functions and how?

Ruben A. Chevez
  • 327
  • 4
  • 9

1 Answers1

4

What you describe sounds like an ideal story for the Google product called Cloud Run. In summary and at the highest level ... Cloud Run lets you run a docker container on demand when an incoming REST request arrives. You are billed for only the duration of execution of your container. When there is no traffic/requests, the container is automatically spun down and you are no longer charged. You can control how many requests are served per container (1 request = 1 container or multiple requests served by the same container or any combinations).

Effectively, Cloud Run is an alternative to Cloud Functions. With Cloud Functions you provide the function body and Cloud Functions provides the environment in which it runs. With Cloud Run, you provide the container which provides the function implementation AND the environment in which it runs. In both cases, Google owns the startup, shutdown and other management of the environment including scaling.

Google on the phrase "GCP Cloud Run" and you will find a wealth of documentation. I strongly suggest that this be your first research area given your described requirement. Please feel free to post additional questions tagged with google-cloud-run if you need further elaboration. If Cloud Run isn't a good answer to your question, please also post back so that we may all understand better.

Kolban
  • 13,794
  • 3
  • 38
  • 60
  • Thank you @Kolban. Do you know if I may be able to mount a folder in that Cloud Run docker from an NFS server that is running in a VM from GCP Compute Engine with public IP? I need to spawn these dockers based on demand but they will all make changes to a single location. (files hosted by a fileserver). – Ruben A. Chevez Dec 20 '19 at 01:55
  • 2
    @RubenA.Chevez - My immediate answer is yes. The container will be running in a network environment that is based on GCP VPC Networks. If you have a Compute Engine serving an NFS server you should be able to reach this. The question (to me) becomes where or not you NEED to reach it via a public IP or whether or not we can access it inside VPC entirely. But that would be a different question. For testing, spin up a Compute Engine with a docker container (eg. Debian or Ubuntu) and login to the container image and test mounting. – Kolban Dec 20 '19 at 02:13
  • Please close off-topic questions. – jww Dec 20 '19 at 03:10
  • CLoud Run has an upper limit of 1 hour for jobs ! Turned out to be completely useless for us. None of our 100 daily jobs have a running time of less than one hour ! – Sanjay Subramanian Jun 02 '23 at 18:24