Upgrade from Retool 3.x to 4.0 (Docker Compose)
Upgrade an existing self-hosted Retool 3.x Docker Compose deployment to Retool 4.0.
Additional requirements introduced in Retool 4.0 include more services and resources. If you have an existing Docker Compose-based staging deployment of self-hosted Retool running 3.x, this guide explains how to upgrade and add the necessary services.
Already running Retool 4.0 or later? Use Upgrade within the Retool 4.x line (Docker Compose) instead. This guide's steps are one-time setup for the 3.x → 4.0 transition and don't apply to later 4.x upgrades.
The upgrade will likely require a larger VM. Plan for a maintenance window and read the whole guide before you start.
This guide is for non-production deployments only. For production, migrate to a Kubernetes deployment using Terraform blueprints.
Retool's officially supported deployment configurations are Helm on Kubernetes and the Docker Compose blueprints. This guide is provided for convenience, but Retool does not provide support guarantees for deployments outside of those configurations. If you are running Docker Compose in production, contact your account team about migrating to a Kubernetes deployment.
Reference configuration files live in the tryretool/retool-onpremise repository.
What changed from Retool 3.x
| Change | Details |
|---|---|
| New services | The reference compose.yaml adds services that Retool 3.x doesn't have, including js-executor, agent-sandbox-controller, agent-sandbox-proxy, r2-agent-worker, and mcp. They start automatically after the upgrade. |
| Blob storage is required | Object storage (S3, Azure Blob, or GCS) is a platform requirement. The reference config includes a bundled MinIO container for non-production use, but production deployments should use a cloud object store. |
| VM size increase required | The new services require significantly more CPU and memory. Plan for at least 8 vCPUs and 64 GiB on the VM. |
| Temporal required for agents | The agent Temporal worker requires a Temporal cluster. If you do not have one, configure Temporal Cloud after deployment. |
| MCP server requires manual configuration on upgrade | The mcp service needs three docker.env variables that install.sh only writes on a fresh install. Add them manually (refer to MCP server below) or MCP clients can't authenticate. |
Before you start
Use this checklist as you prepare the upgrade to ensure you have everything ready.
Follow the standard upgrade best practices in addition to the steps here. Perform the migration during off-peak hours.
Choose your target version
Keeping your deployment up-to-date ensures your organization has access to newer features and security updates. Running a deployment that is multiple releases behind the current one makes each upgrade riskier. Changelogs accumulate more breaking changes and deprecations, incremental migration becomes harder to test, and a large version jump can skip over a release with a required migration step.
If your deployment is more than one stable release behind, upgrade through each stable release in sequence rather than jumping directly to your target version. For example, to upgrade from 3.334 to 4.86:
3.334 -> 4.0 -> 4.34 -> 4.86
Verify each installation before proceeding to the next release. Review the Stable releases or Edge releases page and read all changelogs between your current version and your target version before starting.
Upgrading sequentially through each release is another reason to keep your deployment current: the fewer releases you're behind, the fewer intermediate upgrades you need to perform.
Services overview
This upgrade adds several services to your stack. Some work out of the box; others require a decision or external infrastructure before you start.
| Service | Included in reference config | Action required |
|---|---|---|
| JS Executor | Yes, added by default | None; works out of the box |
| Agent Sandbox | Yes, added by default | None; works out of the box |
| Blob storage | Yes (bundled MinIO) | Recommended: switch to a cloud object store for non-trivial use |
| MCP server | Yes, added by default | Required: add three docker.env variables manually (refer to MCP server below) |
| Temporal + agent Temporal worker | Depends on existing setup | Choose a Temporal path (refer to Temporal below) |
For a full description of each service, refer to the architecture overview.
Blob storage
The reference configuration includes a MinIO container that provides working blob storage with no external dependencies. For development and POC environments, MinIO works without an external store, but an existing installation must add it to its Compose file and docker.env first (refer to Blob storage). For any meaningful use, switch to a cloud object store (S3, Azure Blob, or GCS). The bundled MinIO container uses local VM disk, which will eventually run out of space.
Temporal
The agent Temporal worker requires a Temporal cluster:
- You already have a Temporal cluster: Use your existing cluster, even if it runs locally in your stack. Point the new worker at the same cluster using the Temporal environment variables in Configure the new environment variables.
- You do not have Temporal: Retool recommends Temporal Cloud. Configure it via the in-product setup after deployment (click the Workflows nav item). Temporal Cloud requires outbound egress on ports 443 and 7233. Refer to Temporal egress.
CPU and memory requirements
These services consume meaningful additional CPU and memory. You will most likely need to resize your VM before starting.
For a Retool 4.0 deployment, plan for at least 8 vCPUs and 64 GiB memory. If your current VM is smaller than this, resize it before proceeding.
Pull the latest configuration files
The updated configuration adds the new services to your Compose stack. How you pull it depends on how you manage the repository.
Always get the complete retool-onpremise repository, not just compose.yaml or Dockerfile. The updated configuration also references seccomp profiles and AppArmor scripts elsewhere in the repository. To leave your deployment files unchanged while you compare, download the repository into a separate directory.
Before you pull, note the images your postgres and retooldb-postgres services run. You need them to preserve your customizations:
sudo docker compose ps postgres retooldb-postgres
If you cloned the repository
git stash
git fetch origin
git checkout master
git pull --rebase origin master
# Review and re-apply still necessary changes
git stash show -p
git stash sets aside your local edits, such as the version in your Dockerfile, because git pull --rebase doesn't run with uncommitted changes. git stash show -p lists what it set aside, so you can re-apply what you still need in the following steps. Running git pull inside your existing checkout updates tracked files in place. If you'd rather not change your deployment directory, clone or download into a separate directory instead.
If you did not clone the repository
Download the latest directly:
curl -L https://github.com/tryretool/retool-onpremise/archive/refs/heads/master.zip \
-o retool.zip
unzip retool.zip
Preserve your customizations
Do not overwrite your existing docker.env, Dockerfile, or Compose file wholesale. Reconcile the reference files you pulled against your current setup to keep your license key, SSL settings, and any custom environment variables. Review each file before you rebuild:
| File | What to review |
|---|---|
Dockerfile | Add the new build targets and align the Retool image versions. Keep custom certificates, packages, and startup commands. |
| Compose file | Add the new services and reconcile networks, memory limits, security options, and dependencies. Keep your ports, TLS settings, database images, and volume mappings. |
docker.env | Keep existing keys, secrets, license, database connections, and custom settings. Add the new variables in Configure the new environment variables. |
retooldb.env | Keep your existing Retool Database credentials. |
| Security files | Include nsjail-seccomp.json, gvisor-seccomp.json, the appArmor/ profiles, and scripts/setup-docker-apparmor.sh. Keep the repository directory structure. |
The reference Compose file is compose.yaml. Older instances might use docker-compose.yml instead. If your directory has both files, Compose uses compose.yaml, so move your customizations into it and delete docker-compose.yml.
Keep your existing Compose project name. A different project name causes Compose to create new named volumes instead of reusing the ones that hold your data. If you pass the Compose file explicitly with -f, use the same file in every command in this guide.
After you merge your customizations, compare your Compose file with the reference Compose file and confirm it defines these services and their networks:
js-executoragent-sandbox-controlleragent-sandbox-proxyr2-agent-worker
The reference api service also runs the internal Git server. If you maintain your own api service definition, include the RR_GIT_SERVER role:
environment:
- SERVICE_TYPE=MAIN_BACKEND,DB_CONNECTOR,DB_SSH_CONNECTOR,RR_GIT_SERVER
Environment settings in the Compose file override the same variables in docker.env. Internal Git storage doesn't require you to connect a Git repository of your own.
PostgreSQL can't start on data from an older major version. If the reference compose.yaml runs postgres or retooldb-postgres on a different PostgreSQL major version than the image you noted, set that service's image back to the one you noted. If your PostgreSQL version is older than the minimum Retool supports, upgrade PostgreSQL before you upgrade Retool.
Update your version
Set the new Retool version in your Dockerfile. The stable release is 4.86.2-stable:
ARG VERSION=X.Y.Z-stable # use the tag shown above
ARG CLASSIC_VERSION=X.Y.Z-stable # same version, without the -hardened suffix
FROM tryretool/agent-sandbox-service:${CLASSIC_VERSION} AS agent-sandbox
FROM tryretool/code-executor-service:${VERSION} AS code-executor
FROM tryretool/js-executor-service:${CLASSIC_VERSION} AS js-executor
FROM tryretool/backend:${VERSION}
If you use hardened images, set VERSION to a hardened tag (for example, X.Y.Z-stable-hardened) for backend and code-executor-service. Hardened variants aren't available for agent-sandbox-service or js-executor-service, so keep CLASSIC_VERSION on the non-hardened tag for those two.
Replace X.Y.Z-stable with the stable version from the release notes. If you use a separate CodeExecutor.Dockerfile, update it to the same version.
Configure the new environment variables
install.sh is only for fresh installs. When docker.env already exists, it stops without changing it, so it can't add the new variables below to an existing instance. Add them to your existing docker.env manually, alongside your current values, including ENCRYPTION_KEY and LICENSE_KEY.
Review docker.env and confirm the following are set correctly. This table lists the variables to add and where each is described:
| Group | Variables | Details |
|---|---|---|
| Internal endpoints | WORKFLOW_BACKEND_HOST, CODE_EXECUTOR_INGRESS_DOMAIN, JS_EXECUTOR_INGRESS_DOMAIN | Internal endpoints |
| Agent sandbox | AGENT_EXECUTOR_ENABLED, AGENT_EXECUTOR_CONTROLLER_INGRESS_DOMAIN, AGENT_EXECUTOR_PROXY_INGRESS_DOMAIN, STATE_BACKEND, RR_AGENT_PUBSUB_BACKEND, AGENT_SANDBOX_POSTGRES_URL, AGENT_SANDBOX_POSTGRES_SCHEMA, AGENT_SANDBOX_ENCRYPTION_KEY, AGENT_SANDBOX_JWT_PRIVATE_KEY, AGENT_SANDBOX_JWT_PUBLIC_KEY | Internal endpoints and Agent sandbox |
| Blob storage | RR_BLOB_STORAGE_PROVIDER and the provider settings | Blob storage |
| MCP server | OAUTH_MAIN_DOMAIN, MCP_SERVICE_EXTERNAL_URL, OAUTH_INTROSPECTION_AUTH_TOKEN | MCP server |
| Temporal | WORKFLOW_TEMPORAL_* | Temporal |
Internal endpoints
Retool services reach each other over the Compose networks using these addresses. Add them to docker.env. The values match the service names and ports in the reference compose.yaml:
WORKFLOW_BACKEND_HOST=http://workflows-backend:3000
CODE_EXECUTOR_INGRESS_DOMAIN=http://code-executor:3004
JS_EXECUTOR_INGRESS_DOMAIN=http://js-executor:3000
AGENT_EXECUTOR_ENABLED=true
AGENT_EXECUTOR_CONTROLLER_INGRESS_DOMAIN=http://agent-sandbox-controller:3018
AGENT_EXECUTOR_PROXY_INGRESS_DOMAIN=http://agent-sandbox-proxy:3019
These are internal container addresses. If you renamed a service or changed a port in your Compose file, change the matching value, and confirm the services share a network.
Blob storage
Set the provider and credentials for your chosen object store:
- Amazon S3
- Azure Blob
- GCS
RR_BLOB_STORAGE_PROVIDER=s3
RR_DEFAULT_S3_BUCKET=<your-bucket>
RR_DEFAULT_S3_ACCESS_KEY_ID=<your-key-id>
RR_DEFAULT_S3_SECRET_ACCESS_KEY=<your-secret-key>
RR_DEFAULT_S3_REGION=<your-region>
RR_DEFAULT_S3_ENDPOINT= # optional; for S3-compatible stores
RR_BLOB_STORAGE_PROVIDER=azure
RR_DEFAULT_AZURE_CONNECTION_STRING=<your-connection-string>
RR_DEFAULT_AZURE_CONTAINER=<your-container>
RR_DEFAULT_GCS_CREDENTIALS must be a JSON string for a GCP service account with roles/storage.objectAdmin and roles/storage.bucketViewer.
RR_BLOB_STORAGE_PROVIDER=gcs
RR_DEFAULT_GCS_CREDENTIALS=<json-string>
RR_DEFAULT_GCS_BUCKET=<your-bucket>
New installations get the bundled MinIO configuration from install.sh. An existing installation doesn't have it. To use the bundled MinIO, add the minio and minio-init services, the minio-data volume, the minio-init dependencies on the services that use it, the network configuration, and the matching RR_DEFAULT_S3_*, AWS_ENDPOINT_URL, and MINIO_ROOT_* variables from the reference compose.yaml and install.sh. Otherwise, configure an external object store as described above. If you replace MinIO, remove the minio-init dependencies from your services, and remove leftover MinIO credentials and endpoints from docker.env.
Amazon S3 with an IAM role
For Amazon S3 on an instance with an IAM role, set only the provider, bucket, and region. Leave the static access keys and custom endpoints unset, and remove AWS_ENDPOINT_URL if it's left over from MinIO:
RR_BLOB_STORAGE_PROVIDER=s3
RR_DEFAULT_S3_BUCKET=<your-bucket>
RR_DEFAULT_S3_REGION=<your-region>
Confirm your containers can obtain the role's credentials. The role's policy must allow reading, writing, deleting, and listing objects in the bucket. If the bucket uses SSE-KMS encryption, the role also needs the relevant KMS permissions.
Git and snapshot storage
Retool stores Git data and app snapshots separately from the default blob storage. By default, both use the RR_DEFAULT_* settings. When you set RR_GIT_S3_BUCKET or RR_SNAPSHOTS_S3_BUCKET, that store reads its own RR_GIT_S3_* or RR_SNAPSHOTS_S3_* family of variables instead of falling back to RR_DEFAULT_S3_*. These stores can point to the same bucket as the default:
RR_GIT_S3_BUCKET=<your-bucket>
RR_GIT_S3_REGION=<your-region>
RR_SNAPSHOTS_S3_BUCKET=<your-bucket>
RR_SNAPSHOTS_S3_REGION=<your-region>
If you set a bucket for either store, set the rest of that family's variables, such as the access key and endpoint, if your store needs them. RR_GIT_S3_* and RR_SNAPSHOTS_S3_* each name a family of variables, so don't add a literal * to docker.env. Working default storage doesn't confirm that Git and snapshot storage are configured correctly.
MCP server
The updated configuration adds an mcp service that serves Retool's MCP server at /mcp. It requires HTTPS and three variables in docker.env that install.sh only writes on a fresh install:
# Public host serving OAuth metadata and /api/oauth2/* (your Retool domain, no scheme)
OAUTH_MAIN_DOMAIN=<your-domain>
# Public base URL the MCP server is reachable on, used for import upload URLs
MCP_SERVICE_EXTERNAL_URL=https://<your-domain>
# Shared secret the MCP server presents to the backend's /api/oauth2/introspect.
# Read by both the api and mcp services, so it must match on both.
OAUTH_INTROSPECTION_AUTH_TOKEN=<generate-a-random-value>
Without these variables, the mcp container still starts, but MCP clients fail to authenticate. If you don't want to expose an MCP server, remove the mcp service block from your Compose file instead.
Temporal
The reference compose.yaml includes temporal.yaml by default, which runs a local Temporal cluster alongside Retool. If your instance already uses a Temporal cluster, keep using it. Otherwise, Retool recommends Temporal Cloud.
-
Temporal Cloud (recommended): Comment out the
includeblock in your Compose file and anyWORKFLOW_TEMPORAL_*variables indocker.env. If you haven't set up Temporal Cloud yet, do it in the Retool UI after deployment. -
Existing local cluster: Keep the
includeblock, and confirmdocker.envpoints to the local cluster:WORKFLOW_TEMPORAL_CLUSTER_FRONTEND_HOST=temporalWORKFLOW_TEMPORAL_CLUSTER_FRONTEND_PORT=7233 -
Existing self-managed cluster: Comment out the
includeblock in your Compose file, and confirm the connection variables are present indocker.env:WORKFLOW_TEMPORAL_CLUSTER_FRONTEND_HOST=<host>WORKFLOW_TEMPORAL_CLUSTER_FRONTEND_PORT=<port>WORKFLOW_TEMPORAL_CLUSTER_NAMESPACE=<namespace>If your cluster runs on your own Temporal Cloud account, also set the
WORKFLOW_TEMPORAL_TLS_*variables for mTLS.
Agent sandbox
Without these variables, the agent-sandbox-controller and agent-sandbox-proxy services fail to start.
The agent-sandbox-controller and agent-sandbox-proxy services share state (sandbox assignments, the prewarm pool, and the leader lease) through a Postgres-backed store that uses the existing postgres service instead of requiring a separate Redis deployment. Add these variables to docker.env to configure Postgres usage:
STATE_BACKEND=postgres
RR_AGENT_PUBSUB_BACKEND=postgres
AGENT_SANDBOX_POSTGRES_URL=postgres://<user>:<password>@<postgres-host>:<postgres-port>/<database>
AGENT_SANDBOX_POSTGRES_SCHEMA=agent_executor
AGENT_SANDBOX_ENCRYPTION_KEY=<64-character-hexadecimal-value>
AGENT_SANDBOX_JWT_PRIVATE_KEY=<your-ES256-private-key-pem>
AGENT_SANDBOX_JWT_PUBLIC_KEY=<your-ES256-public-key-base64>
Build AGENT_SANDBOX_POSTGRES_URL from your existing internal storage database settings in docker.env:
| URL part | Existing variable |
|---|---|
| User | POSTGRES_USER |
| Password | POSTGRES_PASSWORD |
| Host | POSTGRES_HOST |
| Port | POSTGRES_PORT |
| Database | POSTGRES_DB |
Do not use the RETOOLDB_POSTGRES_* variables. They configure the separate Retool Database service.
If you're using the bundled postgres container, the host is postgres and the port is 5432. If you've configured an external database such as Amazon RDS, use its host and port. URL-encode special characters in the password, and keep your existing SSL settings. The user must have CREATEDB privilege so the agent sandbox controller can initialize its required database schema.
-
Some sandbox settings accept both
AGENT_EXECUTOR_*andAGENT_SANDBOX_*names. For example,install.shwritesAGENT_EXECUTOR_POSTGRES_URL. Use one name per setting, and don't set the same value under both names. Don't rename every variable in bulk. -
AGENT_SANDBOX_ENCRYPTION_KEYmust be a 64-character hexadecimal value (e.g.,0a1b2c3d4e5f...). Generate one withopenssl rand -hex 32. -
Preserve the encryption key. If you need to restore or recreate the instance, use the same key or the sandbox state becomes unreadable. Generate sandbox keys only the first time you configure the sandbox, not on later upgrades.
-
Generate
AGENT_SANDBOX_JWT_PRIVATE_KEY/AGENT_SANDBOX_JWT_PUBLIC_KEYas an ES256 (EC P-256) PEM pair:openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ae_private.pemopenssl ec -in ae_private.pem -pubout -out ae_public.pem -
AGENT_SANDBOX_JWT_PRIVATE_KEYmust be the raw PEM contents, single-quoted sodocker.envpreserves the line breaks:AGENT_SANDBOX_JWT_PRIVATE_KEY='-----BEGIN EC PRIVATE KEY-----...-----END EC PRIVATE KEY-----' -
AGENT_SANDBOX_JWT_PUBLIC_KEYmust be the PEM contents base64-encoded to a single line. Run:base64 -i ae_public.pem | tr -d '\n'Then set
docker.envto the resulting string, for exampleAGENT_SANDBOX_JWT_PUBLIC_KEY=LS0tLS1CRUdJTi....
Apply the AppArmor profiles
On Linux hosts with AppArmor enabled, such as Ubuntu, the agent sandbox needs Retool's docker-default AppArmor profile. Without it, Docker's built-in version of that profile stops the agent sandbox from starting, so the app builder can't open apps.
Before you run the script, confirm these files from the repository are in your deployment directory:
nsjail-seccomp.jsongvisor-seccomp.jsonscripts/setup-docker-apparmor.shappArmor/docker-defaultappArmor/usr.bin.nsjail
The seccomp profiles must be regular files that contain valid JSON. If a Compose bind-mount source file is missing, Docker creates a directory with that name instead, and the container fails to start.
Run the setup script from the complete retool-onpremise checkout to install the profile. The script reads the companion profiles in appArmor/, so downloading the script alone doesn't work:
./scripts/setup-docker-apparmor.sh
The script uses sudo if you aren't running as root. Hosts without AppArmor skip this step automatically.
On Ubuntu 24.04 and later, Code Executor also needs the usr.bin.nsjail profile. If your instance was installed before install.sh added it, follow the nsjail steps in the AppArmor README, which also explains what each profile changes.
Start the updated deployment
First, validate your Compose file and review the services it defines:
sudo docker compose config --quiet
sudo docker compose config --services
If you use a Compose file name other than the default, add -f <your-file> to every docker compose command. Then rebuild the images from your updated Dockerfile and bring the stack up:
sudo docker compose up -d --build
Without --build, Compose keeps using the images it built for your current version. The initial start can take several minutes as Compose builds the new service images and first-time setup runs.
Restarting a container doesn't apply changes to docker.env or your Compose file. After you change either, recreate the affected service:
sudo docker compose up -d --force-recreate <service-name>
One-shot services such as minio-init exit after they finish. That's expected.
Verify all services are healthy:
sudo docker compose ps
Confirm these services (JS Executor, Agent Sandbox, the agent Temporal workers agent-worker and r2-agent-worker, and MinIO if used) are running alongside your existing containers. If any service is restarting repeatedly or being OOM-killed, the VM likely needs more memory (refer to CPU and memory requirements).
To investigate a failing service:
sudo docker compose logs <service-name>
Complete setup in the Retool UI
Once the deployment is healthy, an admin user should complete the following in the Retool interface:
- Enable Temporal, if you're setting up Temporal Cloud. Navigate to Workflows and follow the in-product setup steps. A valid license key is required.
- Configure your organization to use the app builder.
- Enable Retool AI features. Refer to Enable Retool AI features for the required settings and AI resource prerequisite.
Then verify the upgrade:
- An existing app and a representative resource query work.
- A representative workflow completes, if you use Workflows.
- The app builder generates and previews an app, if you enabled it.
A successful AI resource query doesn't confirm the app builder works. If the builder stops responding, check the logs of the agent-sandbox-controller, agent-sandbox-proxy, and r2-agent-worker services for endpoint, storage, and worker errors.
If you replace the controller-created sandbox containers outside Compose, remove the old ones first using the command in Rollback. This interrupts any active builder sessions.
Complete this verification before you upgrade to another release. Later 4.x upgrades can require configuration changes and database migrations.
Troubleshooting
| Symptom | What to check |
|---|---|
no such service | The Compose file you selected, that the service is defined in it, and the Compose project name. |
| Ingress domain not set or unreachable | The endpoint variable in Internal endpoints, the service name, the port, and that the services share a network. |
| Password authentication failed | The POSTGRES_* mapping in Agent sandbox, URL encoding of the password, and external database settings. |
Git or snapshot storage Invalid URL | The exact variable names, whether you set the bucket for the RR_GIT_S3_* or RR_SNAPSHOTS_S3_* family, and the endpoint format. Refer to Git and snapshot storage. |
AccessDenied or HeadBucket failed | The bucket, region, the identity your containers run as, and the bucket and object permissions. |
| Missing JSON, or a mount source is a directory | That the seccomp profile files exist in your deployment directory as regular files. Refer to Apply the AppArmor profiles. |
| Bundled AppArmor profile not found | That you ran the script from the complete repository checkout, with the appArmor/ profiles beside it. |
| App builder stops responding but the AI resource works | The logs of the sandbox and worker services, blob storage settings, and stale sandbox containers. |
Rollback
If the migration does not go as planned:
-
Run
sudo docker compose downto stop the stack. -
Remove the agent sandbox containers. They keep running after the stack stops, and nothing in Retool 3.x removes them:
sudo docker ps -aq --filter label=com.retool.agent-executor.role=sandbox | xargs -r sudo docker rm -f -
Restore your
Dockerfileto the previous version, and restore your backed-updocker.envand Compose file. If you restoredocker-compose.yml, deletecompose.yaml, because Compose usescompose.yamlwhen both files exist. -
Restore your PostgreSQL snapshot if the database was modified.
-
Bring the previous deployment back up:
sudo docker compose up -d --build.