All posts

The simplest way to make Cloud Run Tomcat work like it should

Your Java app runs great on Tomcat—until someone says, “Let’s move it to Cloud Run.” The container builds. Deploy finishes. Then the logs start whispering about missing ports, hanging threads, and a mysterious readiness probe that never reports ready. Welcome to the cloudy side of Tomcat. Cloud Run handles containers, not servers. Tomcat handles servers, not containers. The mix confuses even experienced engineers because both think they’re in charge. Tomcat expects to bind to port 8080 and hold

Free White Paper

End-to-End Encryption + Sarbanes-Oxley (SOX) IT Controls: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

Your Java app runs great on Tomcat—until someone says, “Let’s move it to Cloud Run.” The container builds. Deploy finishes. Then the logs start whispering about missing ports, hanging threads, and a mysterious readiness probe that never reports ready. Welcome to the cloudy side of Tomcat.

Cloud Run handles containers, not servers. Tomcat handles servers, not containers. The mix confuses even experienced engineers because both think they’re in charge. Tomcat expects to bind to port 8080 and hold court. Cloud Run wants to manage that port itself, routing traffic to whichever instance happens to be awake. The trick is teaching them to share the throne politely.

In short, Cloud Run Tomcat works best when Tomcat behaves like a good container citizen. That means listening on the $PORT environment variable, avoiding daemon threads, and letting Cloud Run handle scale and shutdown. Once that’s clear, everything else starts to click.

How to align Cloud Run and Tomcat
Containerize your app with Tomcat bundled or baked into a base image. In your startup script, read $PORT from the environment and pass it to Tomcat’s connector configuration. Keep startup lightweight—no multi-minute boot rituals or blocking tasks before the first request. Give Cloud Run control over concurrency, scale, and health checks. Treat Tomcat as your servlet runtime, not your orchestrator.

If you integrate identity or session state, route it through managed storage or an external identity provider like Okta or Google Identity Platform. Cloud Run containers are stateless by design, so anything worth saving must live outside the instance.

Best practices for running Tomcat on Cloud Run

Continue reading? Get the full guide.

End-to-End Encryption + Sarbanes-Oxley (SOX) IT Controls: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
  • Use a lightweight Tomcat image, ideally based on distroless or Alpine.
  • Serve static assets from Cloud Storage or CDN instead of the container.
  • Set graceful shutdown hooks so in-flight requests finish cleanly.
  • Rotate secrets with Cloud Secret Manager rather than embedding them.
  • Log to stdout for full visibility in Cloud Logging.

These small steps make Cloud Run Tomcat stable, fast, and compliant with SOC 2 or internal security audits.

The real payoff shows up in developer velocity. No more waiting for a cluster admin to open a port or tune a JVM flag. You push a container and move on. Cloud Run scales in seconds when traffic spikes and vanishes when it slows. Less toil, more code.

Platforms like hoop.dev turn those access rules into guardrails that enforce policy automatically. Instead of relying on manual IAM tweaks or insecure workarounds, hoop.dev ensures your identity and network boundaries stay consistent across every Cloud Run service.

How do I connect Tomcat logs to Cloud Run metrics?
Tomcat logs written to stdout are automatically ingested by Cloud Logging. From there, export metrics to Cloud Monitoring, or push them to any observability tool that supports OpenTelemetry. No custom adapter needed.

Can I use AI copilots with Cloud Run Tomcat?
Yes, but keep data boundaries crisp. AI tools that analyze logs or trace output should use read-only scopes and sanitized payloads. A prompt that exposes environment variables could leak secrets. Automate compliance reviews before feeding anything into external copilots.

A tuned Cloud Run Tomcat setup gives you the simplicity of a managed container with the control of a familiar Java runtime. Stop wrestling your servlet container, and let the platform carry the heavy parts.

See an Environment Agnostic Identity-Aware Proxy in action with hoop.dev. Deploy it, connect your identity provider, and watch it protect your endpoints everywhere—live in minutes.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts