闪电疯狂赛车
91.44M · 2026-03-23
创建目录并构建镜像:
mkdir openclaw
cd openclaw
# 确保Dockerfile已在当前目录
docker build -t ubuntu:24.04.nodejs .
Dockerfile的内容如下:
# Use Ubuntu 24.04 as base image
FROM ubuntu:24.04
# Set environment variables to prevent interactive prompts during build
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
# Replace default apt source with Aliyun mirror (China) using deb822 format
# Ubuntu 24.04+ uses /etc/apt/sources.list.d/ubuntu.sources instead of /etc/apt/sources.list
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/ubuntu.sources &&
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/ubuntu.sources
# Update package list and install essential packages
RUN apt-get update && apt-get install -y
vim
curl
wget
git
htop
net-tools
iputils-ping
sudo
locales
tzdata
&& rm -rf /var/lib/apt/lists/*
# Set locale
RUN locale-gen en_US.UTF-8 &&
update-locale LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
# Set default command to keep container running
CMD ["/bin/bash"]
说明:
ubuntu:24.04.nodejs:基于 Ubuntu 24.04 且预装 Node.js 的自定义镜像-t:指定镜像标签(tag),方便后续引用运行容器并进入交互式 shell:
docker run -it --name openclaw
-p 18789:18789
-p 18791:18791
-p 18792:18792
-p 18293:18793
ubuntu:24.04.nodejs
端口映射说明:
18789:Gateway 主服务端口(Web 访问)18791-18792:其他辅助服务端口18293→18793:额外服务端口映射在容器内执行以下命令:
# 1. 克隆代码仓库
git clone
cd openclaw
# 2. 安装依赖并构建UI
pnpm install && pnpm ui:build && pnpm build
# 3. 设置环境(使用bash shell)
SHELL=bash pnpm setup
# 4. 初始化安装(含配置向导)
openclaw onboard --install-daemon
配置提示: 执行完上述命令后,系统会引导您配置以下关键项:
修改配置文件使 Gateway 可被外部访问:
# 使用 nano 编辑器打开配置文件
vi /root/.openclaw/openclaw.json
找到 gateway->bind 字段,把bind的值修改lan,并保存:
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan", // 改为lan,允许局域网访问
openclaw gateway
说明: Gateway是OpenCLAW的核心服务,负责处理所有请求转发和 API 调用。
openclaw dashboard --no-open
说明:
--no-open:不自动打开浏览器,仅输出 URL 的访问地址,示例如下:如果在浏览器访问时遇到 "pairing required" 错误:
# 1. 列出待配对设备
openclaw devices list

# 2. 批准设备(替换为实际显示的 ID)
openclaw devices approve 40bc4fe0-55a9-4c39-82b7-a1455213fd07
注意事项:
openclaw devices list 输出的实际值为准