Hoy vamos a aprender a instalar OpenClaw en un sistema Docker mediante Docker Compose y dejarlo de forma aislada.
Primero instalamos Docker.
Once installed, we need to update Docker Compose:
# Add official Docker repository curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Update and install sudo apt update sudo apt install docker-compose-plugin
Once installed, we will create our Docker Compose:
services: openclaw-gateway: image: ghcr.io/openclaw/openclaw:latest container_name: openclaw-gateway restart: unless-stopped ports: - "127.0.0.1:18789:18789" environment: - OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN} volumes: - ./config/openclaw/config:/home/node/.openclaw - ./config/openclaw/workspace:/home/node/.openclaw/workspace healthcheck: test: ["CMD", "curl", "-fsS", "http://127.0.0.1:18789/healthz"] interval: 30s timeout: 10s retries: 3 openclaw-cli: image: ghcr.io/openclaw/openclaw:latest container_name: openclaw-cli network_mode: "service:openclaw-gateway" entrypoint: ["node", "dist/index.js"] volumes: - ./config/openclaw/config:/home/node/.openclaw profiles: - cli cap_drop: - NET_RAW - NET_ADMIN security_opt: - no-new-privileges:true
And now we create our .env file:
OPENCLAW_GATEWAY_TOKEN=
We add an arbitrary token, for example with this command you can generate one:
openssl rand -hex 32
If uploaded to git, we create this .gitignore
.env config
docker compose run --rm --no-deps --entrypoint node openclaw-gateway \ dist/index.js onboard --mode local --no-install-daemon docker compose run --rm --no-deps --entrypoint node openclaw-gateway \ dist/index.js config set gateway.bind lan
Start the gateway
docker compose up -d
To open the interface:
http://127.0.0.1:18789
And enter the token mentioned in .env
Some useful commands:
# View real-time logs: docker compose logs -f openclaw-gateway # Stop the gateway: docker compose down # Restart the gateway: docker compose restart openclaw-gateway # Check the health of the service: curl -fsS http://127.0.0.1:18789/healthz # Run the CLI: docker compose run --rm openclaw-cli dashboard --no-open docker compose run --rm openclaw-cli channels login
Add messaging channels
# WhatsApp (scans QR) docker compose run --rm openclaw-cli channels login # Telegram docker compose run --rm openclaw-cli channels add --channel telegram --token "<token>" # Discord docker compose run --rm openclaw-cli channels add --channel discord --token "<token>"
Update to the latest version.
docker compose pull docker compose up -d
References:
– OpenClaw Official Documentation (https://docs.openclaw.ai)
– Docker Installation (https://docs.openclaw.ai/es/install/docker)
— GitHub of OpenClaw (https://github.com/openclaw/openclaw
