Rivet Containers
Rivet Containers allows you to deploy any application packaged as a Docker container to the cloud. Deploy web servers, game backends, or any custom service with complete control over your runtime environment.
What are containers good for?
- High-Memory Workloads: Applications requiring substantial RAM for processing large data. For example, PDF Processing with document parsing and transformation.
- CPU-Heavy Workloads: Tasks demanding significant computational resources. For example, Media Transcoding with FFmpeg for video conversion.
- Browser Automation: Headless browsers for testing, scraping, or rendering. For example, Web Scraping with Puppeteer or Playwright.
- Sandboxed Code Execution: Safely running untrusted code in isolated environments. For example, MMOs or First-Person Shooters.
- Headless Game Servers: Game backends without rendering requirements. For example, Turn-Based Game Logic for chess or card games.
- Custom Dependencies: Applications requiring specific system libraries or tools. For example, Computer Vision Processing with OpenCV dependencies.
Quickstart
Step 1: Writing a Dockerfile
Create a simple HTTP server in your project:
Create a Dockerfile in your project directory:
Ports & environment variables will be passed via the Rivet API
We'll pass the ports & env vars used in the Dockerfile in Step 3. Read more in the API docs for actors.create.
Step 2: Deploying a container
Specify the Dockerfile in your rivet.json
:
Now deploy your container with:
Step 3: Starting a container
In this step, you're requesting Rivet to launch your containerized application in the cloud:
API naming
While this feature is called "Containers" in the UI and documentation, the underlying API uses the term "actors" (e.g., client.actors.create
). This is because there is a lot of overlap between the actor & container APIs.
What happens during creation:
- Rivet finds the latest build matching your
buildTags
- It provisions resources in the specified region (or chooses the best one)
- It starts your container with the provided environment variables
- The container starts running based on your Dockerfile's CMD or ENTRYPOINT
See actors.create for more options.
Step 4: Connecting to a container
Once your container is running, you can access its URL directly from the container object:
What happens during connection:
- Each port configured for your container gets a unique URL
- These URLs are accessible based on your container's security settings
- The URL routes to your container regardless of which region it's in
- For additional security, you can use
getConnection
to generate temporary, authenticated URLs
See actors.get for more details.
Step 5: Destroying a container
When you're finished using the container, it's important to destroy it to free up resources:
What happens during destruction:
- Rivet sends a termination signal to your container
- Your container gets a short grace period to clean up resources
- All compute resources associated with the container are freed
- You stop being billed for the container's runtime
See actors.destroy for more details.
Note
Always destroy containers when you're done with them to avoid unnecessary costs. Containers will continue running and billing will continue until explicitly destroyed.
Configuration Options
When configuring your Docker-based build in rivet.json
, you have access to the following options under builds
:
Option | Description | Example |
---|---|---|
dockerfile | Path to the Dockerfile relative to your project | "Dockerfile" , "docker/prod.Dockerfile" |
image | Use an existing image instead of building | "node:22-alpine" |
build_path | Directory containing your build context | "." , "./backend" |
build_target | Target stage in multi-stage builds | "production" , "development" |
build_args | Key-value pairs passed as build arguments | { "NODE_ENV": "production" } |
See the configuration documentation for all available options.
Non-Root User Requirement
For security reasons, Rivet containers cannot run as root. You must explicitly set a non-root user in your Dockerfile.
Different base images require different commands to create non-root users:
Runtime Details
Memory & CPU Overcommit
Understanding Rivet's memory and CPU resource allocation helps you optimize performance and avoid unexpected container termination.
Note
Monitor your container's resource usage through the Rivet dashboard to ensure you stay within your allocated limits and avoid performance issues or unexpected termination.
Memory Limits
Rivet uses a two-tier memory allocation system:
- Soft limit: This is the memory amount you've reserved on the host machine for your container. This is the target amount you should stay under during normal operation.
- Hard limit: This is set 50% higher than your reserved amount to provide a buffer for unexpected memory spikes. For example, if you reserved 1 GB, your hard limit would be approximately 1.5 GB. Exceeding this hard limit will likely cause your container to be killed.
CPU Throttling
CPU allocation works similarly to memory:
- The CPU percentage you see in monitoring represents what you should follow to avoid getting throttled during periods of resource contention on the host.
- Like memory, the CPU has a mechanism that allows for temporary spikes above your allocated amount, but sustained high usage may result in throttling if there's resource contention.