20

I was trying to run a Docker image with Cloud run and realised that there is no option for adding a persistent storage. I found a list of services in https://cloud.google.com/run/docs/using-gcp-services#connecting_to_services_in_code but all of them are access from code. I was looking to share volume with persistent storage. Is there a way around it ? Is it because persistent storage might not work shared between multiple instances at the same time ? Is there are alternative solution ?

vzurd
  • 1,416
  • 2
  • 15
  • 37

3 Answers3

15

Cloud Run is serverless: it abstracts away all infrastructure management.

Also is a managed compute platform that automatically scales your stateless containers.

Filesystem access The filesystem of your container is writable and is subject to the following behavior:

This is an in-memory filesystem, so writing to it uses the container instance's memory. Data written to the filesystem does not persist when the container instance is stopped.

You can use Google Cloud Storage, Firestore or Cloud SQL if your application is stateful.

3 Great Options for Persistent Storage with Cloud Run

What's the default storage for Google Cloud Run?

marian.vladoi
  • 7,663
  • 1
  • 15
  • 29
6

Having persistent storage in (fully managed) Cloud Run should be possible now. Cloud Run's second generation execution environment (gen2) supports network mounted file systems.

Here are some alternatives:

  1. Cloud Run + GCS: Using Cloud Storage FUSE with Cloud Run tutorial
  2. Cloud Run + Filestore: Using Filestore with Cloud Run tutorial

If you need help deciding between those, check this:

NOTE: At the time of this answer, Cloud Run gen2 is in Preview.

Maikel Ruiz
  • 1,342
  • 2
  • 15
  • 25
5

Cloud Run (fully managed) has known services that's not yet supported including Filestore which is also a persistent storage. However, you can consider running your Docker image on Cloud Run Anthos which runs on GKE and there you can use persistent volumes which are typically backed by Compute Engine persistent disks.

Donnald Cucharo
  • 3,866
  • 1
  • 10
  • 17
  • 1
    I thought Anthos is used when you are using a multi-cloud environment. – vzurd Oct 06 '20 at 17:15
  • Yes that's correct. You install Cloud Run for Anthos on a GKE cluster and that cluster (Anthos) can run on cloud or on-prem but take note that this is just an alternative that I can come up with. If you're interested, you can check out the [quickstart](https://cloud.google.com/run/docs/quickstarts/prebuilt-deploy-gke) guide. – Donnald Cucharo Oct 06 '20 at 17:34