Run OpenClaw in Docker: A Secure Local Setup Guide
Why run OpenClaw inside Docker instead of directly on your system
OpenClaw is designed to operate as an agent runtime with real access to files, shell commands, APIs, browser automation, and messaging integrations. That level of capability makes it powerful — and potentially risky if executed directly on your host machine.
Containerization provides an important security boundary. Running OpenClaw inside Docker helps isolate execution, reduce exposure of local credentials, and create a controlled environment where experiments do not affect your main system.
Instead of granting unrestricted access to your laptop, you define exactly which folders, tools, and permissions are available to the agent.
Typical benefits of a containerized setup include:
- filesystem isolation
- reproducible environment configuration
- easier dependency management
- simplified updates and rollback
- safer testing of experimental agent skills
Installing OpenClaw using Docker Compose
The easiest way to deploy OpenClaw locally is to use the official repository and its predefined Docker configuration.
Start by cloning the repository:
git clone https://github.com/openclaw/openclaw
cd openclaw
The project includes a setup script and a ready-to-use Docker Compose configuration.
Running the setup process creates two important directories on your host machine:
~/.openclaw— configuration, memory storage, API keys, and agent settings~/openclaw/workspace— working directory accessible to the agent
Anything created by the agent inside the container will appear inside the workspace folder.
This separation is intentional:
- configuration data persists between runs
- workspace acts as a controlled sandbox for file manipulation
First-time configuration: key decisions explained
When launching OpenClaw for the first time, you will be prompted with multiple setup options. Some choices significantly affect performance and security.
Onboarding mode
Choose:
manual
Manual onboarding allows full control over gateway configuration and avoids automatic network exposure.
Gateway type
Select:
Local gateway (this machine)
This ensures that the agent runs locally rather than exposing remote endpoints.
Model provider
OpenClaw supports multiple model backends. Depending on your workflow you may choose:
- cloud API models for stronger reasoning
- local models for privacy and offline usage
If you use a hosted provider with authentication, the setup flow may redirect you to a browser and return a localhost callback URL that must be pasted back into the setup interface.
This is expected behavior.
Optional network integrations
Some optional tools (for example mesh networking) may complicate initial setup. If unsure, disable additional networking until the base system works correctly.
Starting and monitoring the containers
Once configured, start OpenClaw:
docker compose up -d
Verify running containers:
docker ps
Typical deployment includes:
- OpenClaw gateway container (agent runtime)
- OpenClaw CLI container (management interface)
Using the CLI container for management tasks
Administrative commands should be executed via the CLI service.
Example:
docker compose run --rm openclaw-cli status
Important note:
Commands must be executed from the directory containing the docker-compose.yml file.
Connecting OpenClaw to Telegram
One of OpenClaw’s strengths is remote interaction through messaging platforms. Telegram is often the easiest integration.
Steps:
- Create a Telegram bot via
@BotFather. - Generate a bot token.
- Provide the token during setup.
- Approve device pairing.
Example approval:
docker compose run --rm openclaw-cli pairing approve telegram <CODE>
After pairing, you can send instructions directly from your phone.
Accessing the Web Dashboard
OpenClaw exposes a web interface, usually on:
http://localhost:18789
Access requires a session token.
If lost, generate a new one:
docker compose run --rm openclaw-cli dashboard --no-open
If you encounter pairing errors, list device requests:
docker compose exec openclaw-gateway \
node dist/index.js devices list
Approve a device:
docker compose exec openclaw-gateway \
node dist/index.js devices approve <ID>
The dashboard provides:
- chat interface
- logs and debugging tools
- skill management
- session monitoring
- resource inspection
Installing additional tools inside the container
The runtime usually runs as a non-root user for safety.
If you need system packages:
docker compose exec -u root openclaw-gateway bash
Example installation:
apt-get update && apt-get install -y ripgrep
Avoid installing unnecessary packages to minimize attack surface.
Security best practices when running OpenClaw in Docker
Running OpenClaw inside a container improves safety but does not eliminate risk.
Recommended practices:
- mount only required directories
- avoid exposing your home folder
- never store SSH keys or production credentials inside workspace
- restrict network access where possible
- rotate API keys regularly
- use dedicated test environments for experiments
Remember:
Agent frameworks blur the line between instructions and execution. Any skill or integration can potentially trigger real system actions.
Typical developer workflows
Developers often use containerized OpenClaw for:
- automated coding assistance
- documentation research
- local file refactoring
- log analysis
- rapid prototyping
- building custom skills
The isolation provided by Docker makes it safer to explore automation without risking primary systems.
Final thoughts
Running OpenClaw in Docker is currently the most practical way to experiment with local AI agents responsibly. Containers provide a balance between flexibility and safety, allowing you to test powerful automation workflows while keeping your main environment protected.
Treat the container as an execution sandbox, carefully manage permissions, and assume that any agent capable of running commands should operate with the least privilege possible.
The combination of local control, container isolation, and modular agent architecture turns OpenClaw into a powerful development companion — without turning your workstation into an uncontrolled experiment.

.png)

