Black Friday Sale - Up to 41% OFF

How to Deploy OpenClaw on Docker

How to Deploy OpenClaw on Docker
Published on Oct 6, 2026 Updated on Nov 27, 2026

OpenClaw is a self-hosted AI assistant that runs on your PC or VPS and connects to messaging apps you already use. As an agentic framework, it plugs into a diverse range of Large Language Models (LLMs), enabling it to handle a multitude of tasks such as workspace management, messaging integrations, and task automation, rather than just answering questions in a chat window.

Because it's agentic by design, OpenClaw needs a stable environment in which its configuration and credentials persist reliably across restarts and upgrades. Docker offers a reliable, resource-efficient way to run applications. With Docker, OpenClaw runs in an isolated container rather than being installed directly on the host OS (VPS or laptop). This ensures it runs more reliably with minimal resource overhead.

This article walks you through deploying OpenClaw with Docker. At the end of this tutorial, you'll have OpenClaw running as a persistent service, with its configuration and workspace safely stored outside the container.

Also read: How to install OpenClaw on a Linux VPS

#Prerequisites

Before you start, make sure you have:

  • A Linux cloud VPS. This guide uses Ubuntu 26.04, configured with sudo access. You can deploy a high-performance, scalable VPS at Cherry Servers to follow along.

  • At least 2 vCPUs and 8GB of RAM. This is a reasonable baseline for 24/7 runtime. Actual requirements will vary depending on how many workflows and tools OpenClaw is running concurrently.

  • An API key for at least one model provider (Anthropic, OpenAI, or Google).

Basic familiarity with the Linux terminal. This guide assumes you're comfortable working in the Linux CLI. Prior Docker experience is preferred but not mandatory.

Scalable VPS Hosting

Deploy fast, secure VPS for websites, apps, and dev environments. Scale on demand, manage with full root access, and get 24/7 expert support.

#Why Deploy OpenClaw With Docker?

Docker is generally a cleaner deployment approach compared to installing OpenClaw directly on the host. The OpenClaw image includes all the packages, libraries, and dependencies needed to run it, enabling seamless dependency management. You won't have to worry about installing the correct Node.js version, dependency conflicts, or handling complex configurations.

Another benefit of containerizing OpenClaw is that you can persist data outside the container by creating persistent directories on the host or VPS. This lets you delete and recreate the container without losing OpenClaw data.

Containerization also makes upgrades and rollbacks easier. Updating OpenClaw is as simple as running a single Docker Compose command. You can also lock a specific image version for more predictable future deployments instead of always using the latest tag.

#Step 1: Update the System & Install Prerequisite Packages

To get started, update the local package index.

Command Line
sudo apt update

Next, install the prerequisite packages required during installation.

Command Line
sudo apt install -y git curl ca-certificates

#Step 2: Install Docker and Docker Compose

Docker is available in Ubuntu's default repositories; however, it doesn't ship with the latest features. The simplest and most reliable path is to install Docker from Docker's official convenience script. To do so, download and run the script using the following commands:

Command Line
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

This installs the Docker engine and the Compose plugin, which lets you manage OpenClaw's containers declaratively through a docker-compose.yml file.

Next, add the logged-in sudo user to the docker group. This helps avoid using sudo when invoking docker commands.

Command Line
sudo usermod -aG docker $USER
newgrp docker

Next, confirm everything is installed correctly:

Command Line
docker --version
docker compose version

Both commands should return the respective versions of Docker and Docker Compose. As of this writing, the latest Docker version is Docker 29.8.0 while the latest Docker Compose version is Docker Compose version v5.5.1.

#Step 3: Download OpenClaw

With Docker in place, download the official OpenClaw repository as follows:

Command Line
git clone https://github.com/openclaw/openclaw.git

Using the ls command, you should see a mix of files and subdirectories.

Command Line
ls  openclaw

The docker-compose.yml file is effectively the deployment itself. It deploys the OpenClaw containers and keeps them running reliably.

#Step 4: Set Up Persistent Storage

This is one of the most critical, and often skipped, steps in real deployment. Docker containers are disposable by design: if you don't explicitly persist OpenClaw's configuration and workspace outside the container, an upgrade or restart can wipe them out.

You certainly don't want to lose your configuration, credentials, workspace, and sessions when you recreate containers. The official setup uses persistent host directories such as:

Command Line
~/.openclaw
~/.openclaw/workspace
~/.openclaw-auth-profile-secrets

To set them explicitly, navigate to the ~/openclaw directory:

Command Line
cd openclaw

Configure the environment variables as follows.

Command Line
export OPENCLAW_CONFIG_DIR="$HOME/.openclaw"
export OPENCLAW_WORKSPACE_DIR="$HOME/.openclaw/workspace"
export OPENCLAW_AUTH_PROFILE_SECRET_DIR="$HOME/.openclaw-auth-profile-secrets"

Verify that the variables are set by running the following commands.

Command Line
echo "$OPENCLAW_CONFIG_DIR"
echo "$OPENCLAW_WORKSPACE_DIR"
echo "$OPENCLAW_AUTH_PROFILE_SECRET_DIR"

You should get the following output.

Output/home/your-username/.openclaw
/home/your-username/.openclaw/workspace
/home/your-username/.openclaw-auth-profile-secrets

Next, use the mkdir command to create the directories.

Command Line
mkdir -p "$OPENCLAW_CONFIG_DIR"
mkdir -p "$OPENCLAW_WORKSPACE_DIR"
mkdir -p "$OPENCLAW_AUTH_PROFILE_SECRET_DIR"

The persistent directories should now be in place.

#Step 5: Launch OpenClaw

With the persistent directories configured, the next step is to launch OpenClaw using Docker Compose.

The official documentation recommends using the pre-built image from GitHub Container Registry instead of building an image locally. Here are a few reasons why.

1. Fewer Resource Requirements

Building from source needs at least 6 GB of RAM. That is more than many small VPS instances or low-spec machines have on hand. Pre-built images use far fewer computing resources since you're downloading a finished image, not compiling one.

2. Time Savings

Compiling from scratch takes much longer than pulling a ready-made image, and you have to redo it every time you want to update. A prebuilt image already has everything needed to run the containers. With one command, you can easily have your containers up and running.

3. Staying Up-To-Date With Less Effort

Several community-maintained pre-built images automatically track upstream releases, with some rebuilding as often as every 6 hours. This means you get the latest version with a simple pull, rather than manually rebuilding and managing updates yourself.

Now that you understand the benefits of using a prebuilt image, we will download an OpenClaw image from the GitHub Container Registry.

First, set the image using the OPENCLAW_IMAGE variable as shown in the command below. The command instructs Compose to pull a ready-made image from the official registry, ghcr.io/openclaw/openclaw, which is also mirrored on Docker Hub as openclaw/openclaw.

Command Line
export OPENCLAW_IMAGE="ghcr.io/openclaw/openclaw:latest"

Finally, run the Docker setup script.

Command Line
./scripts/docker/setup.sh

The script does the following:

Pulls/prepares the OpenClaw image Runs the onboarding process Prompts for your AI provider credentials Generates a Gateway token Launches OpenClaw Gateway Creates configuration files Starts OpenClaw with Docker Compose

#Step 6: Check Running Containers

Once OpenClaw’s onboarding process is complete, verify the OpenClaw container status by running the following command:

Command Line
docker compose ps

This should print the following output.

OutputNAME                          IMAGE                              COMMAND                  SERVICE            CREATED          STATUS                    PORTS
openclaw-openclaw-gateway-1   ghcr.io/openclaw/openclaw:latest   "tini -s -- node dis…"   openclaw-gateway   2 minutes ago   Up 2 minutes (healthy)   0.0.0.0:3978->3978/tcp, [::]:3978->3978/tcp, 0.0.0.0:18789-18790->18789-18790/tcp, [::]:18789-18790->18789-18790/tcp

The output shows the OpenClaw Gateway container is running and its health check is okay. Now let's focus on the exposed ports. You have three exposed ports:

Command Line
0.0.0.0:3978->3978/tcp
0.0.0.0:18789-18790->18789-18790/tcp

This shows that all ports, including the OpenClaw Gateway/Control UI (port 18789), are listening on all network interfaces.

Host port Container port Purpose
3978 3978 OpenClaw service endpoint
18789 18789 OpenClaw Gateway
18790 18790 Gateway-related service

NOTE:

While this setup works fine for a simple test installation or on your home PC, exposing OpenClaw's Gateway port is potentially risky and not recommended since it can be reached externally if your firewall/cloud security group allows it.

From a browser, you can easily access it by browsing http://server-ip:18789. Since this is a VPS, anyone can access the Control UI simply by using your server’s public IP.

We therefore recommend not exposing 18789 publicly; instead, set up an SSH tunnel, which is a much safer option.

#Step 7: Securing OpenClaw

Since Docker publishes all ports on all network interfaces (which is not a recommended security practice), you need to bind the ports to the loopback address,

Open the docker-compose.yml file and scroll to the ports section.

Command Line
nano docker-compose.yml 

By default, this section looks like this.

Command Line
ports:
  - "${OPENCLAW_PORT}:18789"

To bind the ports to the loopback address, edit the port entries to start with 127.0.0.1:

Command Line
ports:
  - "127.0.0.1:${OPENCLAW_PORT}:18789"

Save and exit. Next, validate the compose file by running:

Command Line
docker compose config

If no error is printed, you are good to go.

Since you changed the port mapping, recreate the OpenClaw container by running:

Command Line
docker compose up -d

After recreating the OpenClaw container, two containers now appear to be running and bound to the localhost address.

Command Line
docker compose ps
OutputNAME                          IMAGE                              COMMAND                  SERVICE            CREATED          STATUS                    PORTS
openclaw-openclaw-cli-1       ghcr.io/openclaw/openclaw:latest   "node dist/index.js"     openclaw-cli       15 seconds ago   Up 15 seconds (healthy)
openclaw-openclaw-gateway-1   ghcr.io/openclaw/openclaw:latest   "tini -s -- node dis…"   openclaw-gateway   15 seconds ago   Up 15 seconds (healthy)   127.0.0.1:3978->3978/tcp, 127.0.0.1:18789-18790->18789-18790/tcp

Here’s a summary of the running containers after the port mapping change.

Container Purpose
openclaw-openclaw-gateway-1 Main OpenClaw Gateway — this is the long-running service you normally interact with
openclaw-openclaw-cli-1 CLI container — used for commands such as onboarding, diagnostics, dashboard, etc.

The presence of the openclaw-cli container running separately from the openclaw-gateway container might appear confusing, but it’s perfectly normal.

You haven't accidentally created two OpenClaw installations. Compose creates the CLI service because OpenClaw's Docker setup separates the Gateway and CLI functionality.

You can run a gateway check by executing the command:

Command Line
docker compose run --rm openclaw-cli health

If no errors appear, everything is running fine. You can also follow the Gateway logs in real time to check for errors.

Command Line
docker compose logs -f openclaw-gateway

To stop viewing logs, press CTRL+C.

Additionally, you can test the endpoint health directly by running:

Command Line
curl http://127.0.0.1:18789/healthz

This prints the output shown below.

Output{"ok":true,"status":"live"}

At this point, OpenClaw is installed, running as expected, and configured to listen on the loopback address (127.0.0.1), in line with recommended security practices. The final step is accessing the Control UI from a web browser.

#Step 8: Access the OpenClaw Web UI

Since OpenClaw is bound to the VPS’s loopback address and not publicly exposed, you need to create an SSH tunnel from your local machine to the VPS.

From your laptop or local machine, create an SSH tunnel by running the following command:

Command Line
ssh -N -L 18789:127.0.0.1:18789 [email protected]

Type yes to continue connecting and provide the remote user’s password. After that, you'll notice nothing happens in the terminal. That’s perfectly fine since it’s purely a tunnel.

The command sets up local port forwarding through an SSH connection. It creates a secure SSH tunnel from your computer's port 18789 to port 18789 on the VPS.

Let's flesh out the command in more detail.

ssh: Connect to the VPS via the SSH protocol

[email protected]: Connect to the VPS at that IP as a user called user. In this case, user is the login user configured on the VPS.

-N: Instructs SSH not to execute any remote command. The connection is used purely as a tunnel; it doesn't provide a shell.

-L 18789:127.0.0.1:18789: This is the local forward. It takes the format: -L [local_port]:[destination_host]:[destination_port]. This means port 18789 on the local machine is opened and forwarded through an encrypted SSH connection to port 18789 on the VPS's loopback address.

In simple words, the command connects to the VPS server without opening a shell. It forwards port 18789 on the local machine through that SSH connection to port 18789 on the VPS's localhost.

Once the tunnel is created, head to your browser and browse the URL:

Command Line
http://127.0.0.1:18789

The OpenClaw control UI will be displayed, and you’ll be required to paste the OpenClaw Gateway Token to proceed.

Back in the terminal - still in the OpenClaw folder- retrieve the gateway token by running the following Compose command:

Command Line
docker compose run --rm openclaw-cli gateway auth-token --show

The token is displayed at the end of the output.

Output[+] run 1/1
 ✔ Container openclaw-openclaw-gateway-1 Running                                                                                          0.0s
Container openclaw-openclaw-cli-run-347610e9aa19 Creating
Container openclaw-openclaw-cli-run-347610e9aa19 Created
│
◇

OpenClaw 2026.9.2 (3928bad) — Your second brain, except this one actually remembers where you left things.

f3b5a2c1e79f0e34067b56c3f6a48b4d2af1b3a642c7e18f823831f7509238ba 

Copy and paste it into the Gateway Token field. Then click Connect.

openclaw-control-ui-gateway-token

Finally, this opens the Control UI as shown. From here, you can run a myriad of tasks, including sending messages, streaming live responses, listing paired devices, checking the status of connected messaging platforms (Telegram, WhatsApp, Discord, etc.), and scheduling tasks using cron jobs, to name a few.

openclaw-web-interface

At this point, your OpenClaw deployment has all the essential pieces in place:

A healthy and functional Gateway. A fully functioning CLI container for administrative and diagnostic tasks. Gateway ports bound to 127.0.0.1, keeping them accessible only from the VPS itself. No OpenClaw service ports are directly exposed to the public Internet. Docker Compose is successfully configured and running the Gateway with the updated port bindings. Secure remote access via an SSH tunnel, letting you access the OpenClaw dashboard without exposing the Gateway publicly.

This provides a solid and secure baseline for running OpenClaw on a VPS.

#Conclusion

OpenClaw is now deployed and running. The Gateway is healthy, and the CLI container is available for admin and diagnostics tasks. All Gateway ports are bound to the loopback address only, so nothing is directly exposed to the public internet. A few things worth doing next: set up automated backups for your configuration and data volumes, review the VPS firewall rules, and switch SSH to public-key authentication. Check out the official documentation for more information about OpenClaw.

Read Next

Cloud VPS Hosting

Starting at just $3.51 / month, get virtual servers with top-tier performance.

Share this article

Related Articles

Published on Nov 17, 2026 Updated on Nov 18, 2026

Coolify System Requirements and Server Specs

Discover Coolify server requirements, recommended CPU, RAM and storage specs, supported operating systems, required ports, and the best hosting setup for your workload.

Read More
Published on Nov 12, 2026 Updated on Nov 27, 2026

OpenClaw Cost: Hosting, API and Hidden Costs

Discover how much OpenClaw costs per month, including VPS hosting, AI model APIs, hidden fees, and practical ways to reduce expenses and manage your budget.

Read More
Published on Oct 25, 2026 Updated on Nov 27, 2026

VPS for Coolify: 7 Providers Compared

Compare 7 VPS providers for Coolify, explore server requirements, and find the best hosting option for secure deployments, scalability, backups, and performance.

Read More
No results found for ""
Recent Searches
Navigate
Go
ESC
Exit