Code execution in Cloud Run

A key advantage of using Cloud Run to host AI agents is that it isolates code using its secure execution environment. By building a code sandbox tool in Cloud Run and running it in your container, you can execute application code using any programming language you choose.

Secure two-layer sandboxing

Cloud Run isolates all instances by using a two-layer sandbox that consists of a hardware-backed layer equivalent to individual VMs (x86 virtualization) and a software kernel layer. For more information, see Security design overview.

When you deploy your code, Cloud Run confines the code within the sandboxing environment. This isolation lets you run untrusted code, such as code generated by a large language model (LLM), with greater security. When you execute untrusted code, restrict IAM permissions on your Cloud Run service and use VPC firewall rules to prevent your code from making calls to the internet.

Code execution modes

Cloud Run provides the following modes for code execution:

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月24日 UTC.