Self-host the OpenClaw Gateway
Run a single-user Gateway with Docker Compose on Linux, reach the dashboard over SSH, and keep configuration, sessions and the default workspace on disk. Start with no model or messaging credentials.
What you need
- A Linux VPS you administer, key-based SSH access, Docker Engine 28 or later, Docker Compose 2.24.4 or later, and
curlandopensslon the VPS. The bind-mount ownership steps assume rootful Docker without user namespace remapping. - Room for the official container image, workspace, logs and backups. The downloaded recipe uses a prebuilt image, so upstream’s RAM requirement for building the image locally does not apply.
- A supported model account if you want to send prompts. Check the provider’s usage pricing and authentication terms. Hostodo charges separately for the VPS.
Install and start the Gateway
On the VPS, create a fresh directory and download the Compose file and Gateway configuration. The image is pinned to OpenClaw 2026.11.9 by digest. Run these commands once for a new installation.
(
set -eu
mkdir -m 700 openclaw-gateway
cd openclaw-gateway
umask 077
curl -fSLo compose.yaml https://hostodo.com/downloads/openclaw/compose.yaml
mkdir -m 700 state
curl -fSLo state/openclaw.json https://hostodo.com/downloads/openclaw/openclaw.json
sudo chown -R 1000:1000 state
printf 'OPENCLAW_GATEWAY_TOKEN=%s\n' "$(openssl rand -hex 32)" > .env
docker compose pull
docker compose up -d
)
After installation succeeds, enter openclaw-gateway and run docker compose ps. Once the Gateway is healthy, check it with curl -fsS http://127.0.0.1:18789/healthz.
The container runs as UID/GID 1000. Its port listens on the container network and Docker publishes it only to the VPS’s loopback address. Use a dedicated Compose project and keep other workloads off the Gateway’s network. First startup can take a few minutes. The health endpoint checks liveness. Gateway operations still require authentication.
Connect through an SSH tunnel
Run this command on your own computer. Replace your-user and your-vps with your SSH account and host.
ssh -N -o ExitOnForwardFailure=yes \
-L 127.0.0.1:18789:127.0.0.1:18789 your-user@your-vps
- Keep the SSH session open and visit http://127.0.0.1:18789/. Use this exact address so it matches the configured origin.
- From your private SSH session, open the VPS’s
.envand paste the value afterOPENCLAW_GATEWAY_TOKEN=into the dashboard’s Gateway secret field. If the device needs approval, follow the Control UI instructions. Treat the token as an administrator credential. - Leave both ends of the tunnel on loopback. Keep port 18789 closed to the internet. If the token is exposed, rotate it, recreate the container, and revoke any unfamiliar paired devices.
Add a provider or messaging channel
Use the provider directory to choose a model and the sign-in method your account supports. For a provider that uses an environment key, add its documented variable to the private .env, recreate the container with docker compose up -d, then choose the model in the dashboard. Test with a non-sensitive prompt first.
Add a supported messaging channel only after the private dashboard works. Use pairing or a sender allowlist and verify access from an authorized account. Keep group access closed until needed. The recipe starts with the messaging tool profile and browser automation disabled. Review the Gateway security guide before enabling additional tools or plugins. Container placement alone does not sandbox every tool.
The application can send prompts and relevant context to your model provider and messages and attachments to your connected channel. Review what each service receives before connecting personal or business data.
Back up and restore
Run the backup from the installation directory. It stops the Gateway before archiving its files and restarts it if it was running. The archive can contain credentials, conversations and workspace files. Encrypt it before storing a copy off the VPS.
(
set -eu
umask 077
backup=$(mktemp ../openclaw-backup.XXXXXXXX)
restart=0
stopped=0
finish_backup() {
status=$?
trap '' HUP INT TERM
rm -f -- "$backup" || status=1
if [ "$restart" -eq 1 ]; then
if [ "$stopped" -eq 0 ] && ! docker compose stop gateway; then
exit 1
fi
docker compose up -d || status=1
fi
exit "$status"
}
trap finish_backup EXIT
trap 'exit 129' HUP
trap 'exit 130' INT
trap 'exit 143' TERM
active=$(docker compose ps --status running --status restarting -q gateway)
if [ -n "$active" ]; then
restart=1
fi
docker compose stop gateway
stopped=1
if sudo tar -czf - compose.yaml .env state > "$backup" &&
tar -tzf "$backup" >/dev/null &&
mv -- "$backup" "$backup.tgz"; then
printf 'Backup: %s\n' "$backup.tgz"
else
printf 'Backup failed.\n' >&2
exit 1
fi
)
Run a restore drill in a fresh directory using an archive you created and trust. The restore override removes host port publication and puts the restored Gateway on an internal Docker network. It can then check its state without contacting providers or messaging services.
(
set -eu
mkdir -m 700 openclaw-restore
cd openclaw-restore
sudo tar --numeric-owner -xzf /path/to/openclaw-backup.tgz
sudo chown "$(id -u):$(id -g)" .env
chmod 600 .env
curl -fSLo compose.restore.yaml https://hostodo.com/downloads/openclaw/compose.restore.yaml
suffix=$(openssl rand -hex 8)
project="openclaw-restore-$suffix"
existing=$(docker ps -aq --filter "label=com.docker.compose.project=$project")
if [ -n "$existing" ]; then
printf 'Restore project already exists.\n' >&2
exit 1
fi
printf '%s\n' "$project" > .restore-project
docker compose -p "$project" -f compose.yaml -f compose.restore.yaml pull
docker compose -p "$project" -f compose.yaml -f compose.restore.yaml up -d --pull never
)
Once the drill starts, enter openclaw-restore and check the expected files under state/workspace. When the service is healthy, run the authenticated check from inside the container. Its response should contain "ok": true.
project=$(grep -Ex 'openclaw-restore-[0-9a-f]{16}' .restore-project) &&
docker compose -p "$project" -f compose.yaml -f compose.restore.yaml exec -T gateway sh -c '
node openclaw.mjs gateway call health --url ws://127.0.0.1:18789 \
--token "$OPENCLAW_GATEWAY_TOKEN" --json
'
After verification, stop the drill with the same project name. If you move the workspace, attach other storage or use a database plugin, include those resources in your backup plan. This archive covers the recipe’s single local state directory.
project=$(grep -Ex 'openclaw-restore-[0-9a-f]{16}' .restore-project) &&
docker compose -p "$project" -f compose.yaml -f compose.restore.yaml down
Update deliberately
Check the upstream release notes for security fixes and state migrations. Keep a pre-upgrade backup. Test the replacement image and its digest in a separate environment, update the pin in compose.yaml, then pull and recreate the Gateway. For a rollback that requires older state, use the matching old image and its pre-upgrade backup.
Validation scope
Recipe and upstream references reviewed November 24, 2026. A local Linux container smoke test is separate from Hostodo VPS performance, model calls and messaging delivery.
Upstream Docker installation · Advanced OpenClaw backups · Pinned release