I think you cannot.

I'm familiar with Cloud Run but I'm not familiar with rails.

I assume you'd need to be able to shell into a container in order to be able to run IRB. Generally, you'd do this by asking the runtime (Docker Engine, Kubernetes, Cloud Run) to connect you to the container so that you could do this.

Cloud Run does not (appear) to permit this. I think it's a potentially useful feature request for the service. For those containers that contain shells, this would be the equivalent of GCE's gcloud compute ssh.

Importantly, your app may be serviced by multiple, load-balanced containers and so you'd want to be able to console into any of these.

However, you may wish to consider alternatives mechanisms for managing your app: monitoring, logging, trace etc. These mechanisms should provide you with sufficient insight into your app's state. Errant container instances should be terminated.

This follows the concept of "pets vs. cattle" whereby, instead of nurturing individual containers (is one failing?), you nurture the containers holistically (is the service comprising many containers failing?)

For completeness, if you think that there's an issue with a container image that you're unable to resolve through other means, you could run the image elsewhere (e.g. locally) where you can use IRB. Since the same container image will behave consistently wherever it's run, you should be able to observe the issue using IRB locally too.

Answer from DazWilkin on Stack Overflow
🌐
Google
docs.cloud.google.com › ruby › running rails on the cloud run environment
Running Rails on the Cloud Run environment | Ruby | Google Cloud Documentation
The code for the Rails sample app is in the GoogleCloudPlatform/ruby-docs-samples repository on GitHub. ... Go to the directory that contains the sample code and run the following commands to make sure that the application is properly set up with the required gems and dependencies: ... This tutorial uses a number of Google Cloud services to provide the database, media storage, and secret storage that support the deployed Rails project.
🌐
GitHub
github.com › mattes › google_cloud_run
GitHub - mattes/google_cloud_run: Rails on Google Cloud Run
I'd recommend to create two different Cloud Run services. One for HTTP requests (aka Heroku Dynos) and another service for jobs (aka Heroku Workers). Set the Request Timeout for the request-bound service to something like 15s, and for workers to 1800s or match config.google_cloudrun.job_timeout_sec. Cloud Task execution calls are authenticated with a Google-issued OIDC token. So even though /rails/google_cloudrun/job_callback is publicly available, without a valid token, no job will be executed.
Starred by 10 users
Forked by 2 users
Languages   Ruby 89.5% | HTML 8.2% | JavaScript 1.2% | CSS 1.1% | Ruby 89.5% | HTML 8.2% | JavaScript 1.2% | CSS 1.1%
🌐
Medium
medium.com › google-cloud › google-cloud-run-on-rails-a-real-life-example-part-1-preparing-the-ground-705c94ab8a7a
Google Cloud Run on Rails: a real life example (Part 1: preparing the ground) | by Laurent Julliard | Google Cloud - Community | Medium
May 23, 2019 - Cloud Build to build the container image of your application and deploy it to Cloud Run · Container Registry to store and uniquely identify a version of your container image as well as check it against vulnerabilities · Cloud SQL to manage your production MySQL database at scale · Cloud Storage as the Rails Active Storage backend to store picture files
🌐
Google Skills
skills.google › focuses › 20049
Use Ruby on Rails with Cloud SQL for PostgreSQL on Cloud Run | Google Skills
February 18, 2026 - In this lab, you'll learn how to deploy a new Ruby on Rails application using Google Cloud SQL for PostgreSQL on Cloud Run.
🌐
Keypup
keypup.io › blog › deploying-production-rails-applications-to-gcp
Deploying production Rails applications to Google Cloud ...
December 19, 2023 - This guide is a tour of all the base services you will need to deploy a scalable Rails application to Google Cloud Platform. Deploy your app, run it, monitor its performance, connect your datastores, run background jobs and share events between your microservice apps.
🌐
Medium
medium.com › @gjcarew › deploying-to-google-cloud-run-980fdbcd7b34
Deploying a Rails app to GCP Cloud Run | by Gavin Carew | Medium
April 17, 2023 - WORKDIR /usr/src/app COPY Gemfile Gemfile.lock ./ ENV BUNDLE_FROZEN=true RUN bundle install # Copy local code to the container image. COPY . ./ # Environment ENV RAILS_ENV production ENV RAILS_MAX_THREADS 60 ENV RAILS_LOG_TO_STDOUT true # These are links to your secrets. Sub these with your own links. # If you forget where you put your keys, from your console go to # Cloud Storage >> Buckets ENV MOVIES_API_KEY_LINK [MY_BUCKET]/movies-api-key ENV RAILS_MASTER_KEY_LINK [MY_BUCKET]/master.key ENV DB_USERNAME_LINK [MY_BUCKET]/prod-db-username ENV DB_PW_LINK [MY_BUCKET]/prod-db-password # Run the web service on container startup.
Find elsewhere
Top answer
1 of 2
4

I think you cannot.

I'm familiar with Cloud Run but I'm not familiar with rails.

I assume you'd need to be able to shell into a container in order to be able to run IRB. Generally, you'd do this by asking the runtime (Docker Engine, Kubernetes, Cloud Run) to connect you to the container so that you could do this.

Cloud Run does not (appear) to permit this. I think it's a potentially useful feature request for the service. For those containers that contain shells, this would be the equivalent of GCE's gcloud compute ssh.

Importantly, your app may be serviced by multiple, load-balanced containers and so you'd want to be able to console into any of these.

However, you may wish to consider alternatives mechanisms for managing your app: monitoring, logging, trace etc. These mechanisms should provide you with sufficient insight into your app's state. Errant container instances should be terminated.

This follows the concept of "pets vs. cattle" whereby, instead of nurturing individual containers (is one failing?), you nurture the containers holistically (is the service comprising many containers failing?)

For completeness, if you think that there's an issue with a container image that you're unable to resolve through other means, you could run the image elsewhere (e.g. locally) where you can use IRB. Since the same container image will behave consistently wherever it's run, you should be able to observe the issue using IRB locally too.

2 of 2
0

Conventionally, as DazWilkin pointed out, it's not possible.

However, there is a workaround.

https://github.com/rails/web-console

This allows you to access the console via a browser section. Please note that this poses a significant security risk, be aware.

🌐
GitHub
github.com › ejangi › rails-google-cloud-run
GitHub - ejangi/rails-google-cloud-run: A test deployment of a Rails 6 app to Google Cloud Run using Cloud Build · GitHub
A test deployment of a Rails 6 app to Google Cloud Run using Cloud Build - ejangi/rails-google-cloud-run
Author   ejangi
🌐
Google
docs.cloud.google.com › ruby › run rails 7 on app engine flexible environment
Run Rails 7 on App Engine flexible environment | Ruby | Google Cloud Documentation
Install the Google Cloud CLI. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity. To initialize the gcloud CLI, run the following command: ... Install Ruby version 3.0 or later.
🌐
GitHub
gist.github.com › iEv0lv3 › 8f877bbd3d27f6a670435bda0650d7d8
GCP Cloud Run :: Docker :: Rails · GitHub
This guide covers deploying a Docker image of a Rails and PostgreSQL application on Google Cloud Platform using Cloud Build, Container Registry, Cloud Key Management Service, Cloud Run, Cloud SQL, and Cloud Store.
🌐
Coursera
coursera.org › browse › information technology › cloud computing
Using Ruby on Rails with Cloud SQL for PostgreSQL on Cloud Run
This is a self-paced lab that takes place in the Google Cloud console. In this lab, you'll learn how to deploy a new Ruby on Rails application using Google Cloud SQL for PostgreSQL on Cloud Run.
🌐
DEV Community
dev.to › ljulliar › deploying-a-rails-app-on-google-cloud-run-4jhl
Deploying a Rails app on Google Cloud Run - DEV Community
May 21, 2019 - My intent with this tutorial is to go beyond the "usual Hello World" application and show what it means to deploy a Rails application in production on a container based, serverless service like Cloud Run.
🌐
Medium
medium.com › @palladiusbonton › ruby-on-rails-with-postgresql-on-cloud-run-bdaaf0b26e0b
Level Up Your Rails Game with Cloud Run: A Qwiklabs Deep Dive | by Riccardo Carlesso | Medium
August 15, 2024 - In this video, I walk you through me executing the steps described in Ruby on Rails with PostgreSQL on Cloud Run on cloudskillsboost website, encountering a few bumps along the road, and fixing them. Plus I show you my personal Dev Toolchain
🌐
DEV Community
dev.to › sumiki › rails6-on-google-cloud-run-5k3
Rails6 on Google Cloud Run - DEV Community
July 15, 2020 - # Gemfile FROM ruby:2.7 WORKDIR /app COPY Gemfile Gemfile.lock ./ ENV RAILS_ENV production RUN bundle install COPY . . EXPOSE 3000 ENV RAILS_SERVE_STATIC_FILES true CMD ["bin/rails", "server", "-b", "0.0.0.0"] ... GOOGLE_CLOUD_PROJECT=<your project name> docker tag cloud_run_rails:0.0.1 us.gcr.io/${GOOGLE_CLOUD_PROJECT}/cloud_run_rails:0.0.1 docker push us.gcr.io/${GOOGLE_CLOUD_PROJECT}/cloud_run_rails:0.0.1
🌐
Stack Overflow
stackoverflow.com › questions › 58540936 › unable-to-deploy-rails-app-into-google-cloud-run
docker - Unable to deploy Rails app into Google Cloud Run - Stack Overflow
October 24, 2019 - $ gcloud beta run deploy whale-on-rails --image gcr.io/$PROJECT_ID/whale_on_rails \ 4m 58s Ruby 2.6.5 --set-cloudsql-instances whale-on-rails-production \ --region us-central1 --allow-unauthenticated --platform managed
🌐
DEV Community
dev.to › hadyrashwan › ruby-on-rails-with-google-cloud-run-4hb
Google Cloud Run and MySql using Ruby On Rails - DEV Community
August 25, 2020 - Click on Connect with cloud shell. Connect using gcloud by pressing enter in the terminal you should see a similar command shown in your shell. Enter the root password that you choice earlier and press enter.
🌐
Medium
medium.com › google-cloud › google-cloud-run-on-rails-a-real-life-example-part-4-going-live-64c566b73b7b
Google Cloud Run on Rails: a real life example (Part 4: going live!) | by Laurent Julliard | Google Cloud - Community | Medium
May 23, 2019 - In addition to gathering system and application log messages, Cloud Run also collect a number of metrics like Request Count, Request Latency as well as Container CPU and memory allocation. Metrics are available from the tab of the same name (see screenshot above). Collecting Rails logs with Cloud Run is a first step.