内容目录
由于官方镜像无法安装浏览器,故使用如下方式
根据镜像 ubuntu:22.04 创建新的带有浏览器(google-chrome)和openclaw 的新镜像,
通过新镜像创建容器,使用 openclaw ,此时openclaw 可使用root 权限
一、创建 Dockerfile
# 基础镜像:Ubuntu 22.04(LTS,支持完整systemd) FROM ubuntu:22.04 # 避免交互提示 + 中文环境 + 固定Node版本 ENV DEBIAN_FRONTEND=noninteractive ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 ENV OPENCLAW_SKIP_ONBOARD=1 ENV NODE_ENV=production ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # 1. 安装核心依赖 + Node.js + screen + DNS工具 RUN apt update && apt install -y \ systemd \ systemd-sysv \ wget \ gnupg2 \ apt-transport-https \ ca-certificates \ fonts-wqy-microhei \ locales \ curl \ git \ net-tools \ iproute2 \ sudo \ bash \ screen \ && rm -rf /var/lib/apt/lists/* # 2. 配置中文环境 RUN locale-gen zh_CN.UTF-8 && update-locale LC_ALL=zh_CN.UTF-8 # 4. 安装 Google Chrome RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ && apt update && apt install -y google-chrome-stable \ && rm -rf /var/lib/apt/lists/* # 5. 安装 OpenClaw 核心(基于已安装的Node.js) RUN /bin/bash -c "curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard" # 7. 清理systemd无关配置(仅保留基础功能,移除自启动相关) RUN rm -f /etc/systemd/system/*.wants/*apt-daily* \ && systemctl mask getty.target console-getty.service \ && rm -f /etc/systemd/system/openclaw-gateway.service || true # 暴露网关端口 EXPOSE 18789 # 入口:systemd(保留基础systemctl功能,无自启动) CMD ["/sbin/init"]
二、构建 & 启动 & 验证
1. 强制清理缓存 + 构建(确保无残留)
# 清理所有Docker构建缓存 docker builder prune -af # 构建镜像(全程无报错) docker build --no-cache -t ubuntu-chrome-openclaw:22.04 .
可将镜像文件导出 , 移植到其他Docker中
2. 启动容器
docker run -d \ --name chrome-openclaw \ -p 18789:18789 \ ubuntu-chrome-openclaw:22.04
3. 验证核心功能
# 进入容器 docker exec -it chrome-openclaw bash # 1. 验证screen screen --version # 输出screen版本 # 2.验证google-chrome google-chrome --version # 安装openclaw openclaw onboard --install-daemon
三、screen 使用示例(后台运行网关)
openclaw gateway start 与 openclaw gateway install 不可用
故后台运行 如下
# 进入容器 docker exec -it chrome-openclaw bash # 创建screen会话启动网关 screen -S openclaw-gateway openclaw gateway # 按 Ctrl+A+D 退出screen(网关后台运行) # 重新连接会话 screen -r openclaw-gateway # 列出所有screen会话 screen -ls
四、openclaw.json
具体介绍请至官网查看 https://docs.openclaw.ai/
使用时 按需取用,使用时需要去除注释
{
"meta": { //自动生成
"lastTouchedVersion": "2026.3.13",
"lastTouchedAt": "2026-03-20T04:14:15.900Z"
},
"env": { // 三方AI apikey 存放处
"ZAI_API_KEY": ""
},
"wizard": { // 自动生成
"lastRunAt": "2026-03-20T02:57:02.223Z",
"lastRunVersion": "2026.3.13",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"browser": { // 使用浏览器
"executablePath": "/usr/bin/google-chrome", // 根据安装浏览器可更换地址
"headless": true,
"noSandbox": true,
"defaultProfile": "openclaw"
},
"auth": {
"profiles": { //三方api 存放授权处
"github-copilot:github": { // openclaw 官方文档 安装github-copilot 自动生成
"provider": "github-copilot",
"mode": "token"
}
}
},
"models": { //模型配置
"mode": "merge",
"providers": {
"zai": { // 完整模型 配置
"baseUrl": "https://open.bigmodel.cn/api/paas/v4",
"api": "openai-completions",
"models": [
{
"id": "glm-4.7-flash",
"name": "GLM-4.7 Flash",
"reasoning": true,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
},
{
"id": "GLM-4V-Flash",
"name": "GLM-4V-Flash",
"reasoning": true,
"input": [
"image"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
}
]
}
}
},
"agents": {
"defaults": { // 默认会话
"model": {
"primary": "github-copilot/gpt-4o" // 默认会话 使用模型配置处
},
"models": { // 已配置模型 加载
"zai/glm-4.7-flash": {
"alias": "GLM"
},
"zai/GLM-4V-Flash": {
"alias": "GLM"
},
"github-copilot/gpt-4o": {}
},
"workspace": "/root/.openclaw/workspace",
"sandbox":{ // 沙箱配置
"browser":{ // 浏览器 沙箱内可用
"enabled":true
}
}
}
},
"tools": {
"profile": "full" // full 可使用系统所有命令
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"session": {
"dmScope": "per-channel-peer"
},
"hooks": {
"internal": {
"enabled": true,
"entries": {
"boot-md": {
"enabled": true
},
"bootstrap-extra-files": {
"enabled": true
},
"command-logger": {
"enabled": true
},
"session-memory": {
"enabled": true
}
}
}
},
"channels": {
"feishu": { // 飞书渠道,若开始安装未安装飞书插件,通过此处配置
"enabled": true,
"appId": "",
"appSecret": "",
"connectionMode": "websocket",
"domain": "feishu",
"groupPolicy": "open"
}
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan", // lan 可公网访问
"controlUi": {
"allowedOrigins": [ // 若需要公网管理端访问 需要增加 https 的地址在其中
"http://localhost:18789",
"http://127.0.0.1:18789",
],
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true // true 时 公网访问 否则会有拦截
},
"auth": {
"mode": "token",
"token": ""
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add",
"sms.send"
]
}
},
"skills": {
"install": {
"nodeManager": "npm"
}
},
"plugins": {
"entries": {
"feishu": {
"enabled": true
}
},
"installs": {
"feishu": {
"source": "npm",
"spec": "@openclaw/feishu",
"installPath": "/root/.openclaw/extensions/feishu",
"version": "2026.3.13",
"resolvedName": "@openclaw/feishu",
"resolvedVersion": "2026.3.13",
"resolvedSpec": "@openclaw/feishu@2026.3.13",
"integrity": "sha512-D5vPkgGZ9lfCQnDFlGrQN6NCSUYRgYW9k7amW3qlm9zBI4Sp+alRZVqLZ4yZ2eCXHjw9RVp/L75wjJ7NBQyfEw==",
"shasum": "39128ff918f8d3387331818cbe3f8b24a82e4c0d",
"resolvedAt": "2026-03-19T06:22:15.053Z",
"installedAt": "2026-03-19T06:23:05.974Z"
}
}
}
}