RK3528 小主機:Docker 與第一隻龍蝦安裝指令(本機版)

說明

1. 更新系統套件

確保系統是最新,避免安裝 Docker 時遇到相依性問題。

sudo apt update
sudo apt upgrade -y

2. 安裝 Docker 所需套件

安裝憑證與套件庫管理相關工具。

sudo apt install -y ca-certificates curl gnupg lsb-release

3. 設定 Docker 官方套件庫

加入 Docker 官方 GPG 金鑰與 apt 套件庫來源。

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update

4. 安裝 Docker CE

安裝 Docker 伺服器與命令列工具。

sudo apt install -y docker-ce docker-ce-cli containerd.io

5. 將目前使用者加入 docker 群組

讓之後可以不用每次都打 sudo 執行 docker。

sudo usermod -aG docker $USER

重要:執行完這行後,請「登出再登入一次」或直接重開機一次,權限才會生效。

6. 測試 Docker 是否正常(hello-world)

這一步會從 Docker Hub 下載 hello-world 映像並執行一次容器。

docker run --rm hello-world

看到「Hello from Docker!」訊息代表 Docker 安裝成功。

7. 建立第一隻龍蝦用的本機資料夾

先用本機家目錄儲存設定與 log,之後再換成 NAS 也可以。

mkdir -p ~/openclaw/config
mkdir -p ~/openclaw/logs

8. 下載 OpenClaw 映像檔

拉取最新版本的 OpenClaw 容器映像(目前假設映像名稱為 openclaw/openclaw:latest)。

docker pull openclaw/openclaw:latest

9. 建立 OpenClaw 設定檔 (.env)

基本環境變數設定,之後若有 API Key 或模型路由可再補上。

cat << 'EOF' > ~/openclaw/config/.env
OPENCLAW_HOME=/data
OPENCLAW_LOG_LEVEL=info
# 之後你有 API Key / 模型路由設定,可以再加在這裡
EOF

10. 啟動第一隻龍蝦容器(openclaw1)

建立並啟動一個常駐的 OpenClaw 容器實例,開機自動重啟。

docker run -d \
  --name openclaw1 \
  --restart=unless-stopped \
  --env-file ~/openclaw/config/.env \
  -v ~/openclaw/config:/data/config \
  -v ~/openclaw/logs:/data/logs \
  openclaw/openclaw:latest

11. 檢查容器狀態與啟動 log

確認 openclaw1 是否正常運作。

docker ps
docker logs --tail 50 openclaw1

若 log 中沒有重大錯誤訊息,表示第一隻龍蝦已經啟動。

12. 使用 CLI 跟龍蝦互動(help / chat)

查看 OpenClaw CLI 可用指令:

docker exec -it openclaw1 openclaw help

若要進入互動式聊天/指令模式(視實際 CLI 支援而定):

docker exec -it openclaw1 openclaw chat

若上述指令顯示「找不到 openclaw 指令」或其他錯誤,請記下完整錯誤訊息,回來調整映像名稱或 CLI 名稱。