Skip to main content
Run a persistent OpenClaw Gateway on a GCP Compute Engine VM using Docker, with durable state, baked-in binaries, and safe restart behavior. Pricing varies by machine type and region; pick the smallest VM that fits your workload and scale up if you hit OOMs. The Gateway can be accessed via SSH port forwarding from your laptop, or via direct port exposure if you manage firewalling and tokens yourself. This guide uses Debian on GCP Compute Engine. Ubuntu also works; map packages accordingly. For the generic Docker flow, see Docker.

What you need

  • GCP account (e2-micro is free-tier eligible)
  • gcloud CLI, or the Cloud Console
  • SSH access from your laptop
  • Docker and Docker Compose
  • Model auth credentials
  • Optional provider credentials (WhatsApp QR, Telegram bot token, Gmail OAuth)
  • ~20-30 minutes

Quick path

  1. Create a GCP project, enable billing and the Compute Engine API
  2. Create a Compute Engine VM (e2-small, Debian 12, 20GB)
  3. SSH into the VM, install Docker
  4. Clone the OpenClaw repository
  5. Create persistent host directories
  6. Configure .env and docker-compose.yml
  7. Bake required binaries, build, and launch
1

Install gcloud CLI (or use Console)

Install from cloud.google.com/sdk/docs/install, then:
Or do every step below through the Cloud Console web UI instead.
2

Create a GCP project

Enable billing at console.cloud.google.com/billing (required for Compute Engine).Console equivalent: IAM & Admin > Create Project, enable billing, then APIs & Services > Enable APIs > “Compute Engine API” > Enable.
3

Create the VM

TypeSpecsCostNotes
e2-medium2 vCPU, 4GB RAM~$25/moMost reliable for local Docker builds
e2-small2 vCPU, 2GB RAM~$12/moMinimum recommended for a Docker build
e2-micro2 vCPU (shared), 1GB RAMFree tier eligibleOften fails with Docker build OOM (exit 137)
4

SSH into the VM

Console: click “SSH” next to the VM in the Compute Engine dashboard.SSH key propagation can take 1-2 minutes after VM creation; wait and retry if connection is refused.
5

Install Docker (on the VM)

Log out and back in for the group change to take effect, then SSH back in:
Verify:
6

Clone the OpenClaw repository

This guide builds a custom image so any binaries you bake in survive restarts.
7

Create persistent host directories

Docker containers are ephemeral; all long-lived state must live on the host.
8

Configure environment variables

Create .env in the repository root:
Set OPENCLAW_GATEWAY_TOKEN to manage the stable gateway token through .env; otherwise configure gateway.auth.token before relying on clients across restarts. If neither is set, OpenClaw uses a runtime-only token for that startup. Generate a keyring password for GOG_KEYRING_PASSWORD:
Do not commit this file. It holds container/runtime env such as OPENCLAW_GATEWAY_TOKEN. Stored provider OAuth/API-key auth lives in the mounted ~/.openclaw/agents/<agentId>/agent/auth-profiles.json.
9

Docker Compose configuration

Create or update docker-compose.yml:
--allow-unconfigured is only for bootstrap convenience, not a substitute for real gateway configuration. Still set auth (gateway.auth.token or password) and a safe bind mode for your deployment.
10

Shared Docker VM runtime steps

Follow the shared runtime guide for the common Docker host flow:
11

GCP-specific launch notes

If the build fails with Killed or exit code 137 during pnpm install --frozen-lockfile, the VM is out of memory. Use e2-small at minimum, or e2-medium for more reliable first builds.When binding to LAN (OPENCLAW_GATEWAY_BIND=lan), configure a trusted browser origin before continuing:
Replace 18789 with your configured port if you changed it.
12

Access from your laptop

Create an SSH tunnel to forward the Gateway port:
Open http://127.0.0.1:18789/ in your browser.Reprint a clean dashboard link:
If the UI prompts for shared-secret auth, paste the configured token or password into Control UI settings (this Docker flow writes a token by default; use your configured password instead if you switched to password auth).If Control UI shows unauthorized or disconnected (1008): pairing required, approve the browser device:
See Docker VM Runtime for the shared persistence map and update flow.

Troubleshooting

SSH connection refused SSH key propagation can take 1-2 minutes after VM creation. Wait and retry. OS Login issues Check your OS Login profile:
Ensure your account has the required IAM permissions (Compute OS Login or Compute OS Admin Login). Out of memory (OOM) If the Docker build fails with Killed and exit code 137, the VM was OOM-killed:

Service accounts (security best practice)

For personal use, your default user account works fine. For automation or CI/CD, create a dedicated service account with minimal permissions:
Avoid the Owner role for automation; use the narrowest role that works. See Understanding roles.

Next steps