Container Runtime
Rivet supports deploying containerized applications using Docker. Your application can be packaged in a standard Dockerfile, giving you complete flexibility for your runtime environment.
This guide is for advanced usage of Rivet
For getting started quickly, we recommend using ActorCore.
Basic Setup
Step 1: Writing a Dockerfile
Create a simple HTTP server in your project:
Create a Dockerfile in your project directory:
Step 2: Deploying a container
Specify the Dockerfile in your rivet.json
:
Now deploy your container with:
Step 3: Starting an actor
In this step, you're requesting Rivet to launch your containerized application in the cloud:
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 an actor
Once your container is running, you can access its URL directly from the actor object:
What happens during connection:
- Each port configured for your actor gets a unique URL
- These URLs are accessible based on your actor's security settings
- The URL routes to your actor 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 an actor
When you're finished using the actor, 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 actor are freed
- You stop being billed for the actor's runtime
See actors.destroy for more details.
Note
Always destroy actors when you're done with them to avoid unnecessary costs. Actors 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: