Sandbox CLI

격리된 agent 실행을 위한 Docker 기반 샌드박스 컨테이너를 관리합니다.

개요

OpenClaw는 보안을 위해 격리된 Docker 컨테이너에서 agent를 실행할 수 있습니다. sandbox 명령은 업데이트 또는 구성 변경 후 이러한 컨테이너를 관리하는 데 도움이 됩니다.

명령

openclaw sandbox explain

효과적인 샌드박스 mode/scope/workspace 접근, 샌드박스 tool policy 및 elevated gate를 검사합니다 (수정 가능한 config key 경로 포함).

openclaw sandbox explain
openclaw sandbox explain --session agent:main:main
openclaw sandbox explain --agent work
openclaw sandbox explain --json

openclaw sandbox list

상태 및 구성과 함께 모든 샌드박스 컨테이너를 나열합니다.

openclaw sandbox list
openclaw sandbox list --browser  # browser 컨테이너만 나열
openclaw sandbox list --json     # JSON 출력

출력에 포함됨:

  • 컨테이너 이름 및 상태 (running/stopped)
  • Docker 이미지 및 config와 일치 여부
  • Age (생성 이후 시간)
  • Idle time (마지막 사용 이후 시간)
  • 연결된 session/agent

openclaw sandbox recreate

업데이트된 이미지/config로 강제 재생성하기 위해 샌드박스 컨테이너를 제거합니다.

openclaw sandbox recreate --all                # 모든 컨테이너 재생성
openclaw sandbox recreate --session main       # 특정 session
openclaw sandbox recreate --agent mybot        # 특정 agent
openclaw sandbox recreate --browser            # browser 컨테이너만
openclaw sandbox recreate --all --force        # 확인 건너뛰기

옵션:

  • --all: 모든 샌드박스 컨테이너 재생성
  • --session <key>: 특정 session의 컨테이너 재생성
  • --agent <id>: 특정 agent의 컨테이너 재생성
  • --browser: browser 컨테이너만 재생성
  • --force: 확인 프롬프트 건너뛰기

중요: 컨테이너는 agent가 다음에 사용될 때 자동으로 재생성됩니다.

사용 사례

Docker 이미지 업데이트 후

# 새 이미지 pull
docker pull openclaw-sandbox:latest
docker tag openclaw-sandbox:latest openclaw-sandbox:bookworm-slim

# 새 이미지를 사용하도록 config 업데이트
# config 편집: agents.defaults.sandbox.docker.image (또는 agents.list[].sandbox.docker.image)

# 컨테이너 재생성
openclaw sandbox recreate --all

샌드박스 구성 변경 후

# config 편집: agents.defaults.sandbox.* (또는 agents.list[].sandbox.*)

# 새 config 적용을 위해 재생성
openclaw sandbox recreate --all

setupCommand 변경 후

openclaw sandbox recreate --all
# 또는 하나의 agent만:
openclaw sandbox recreate --agent family

특정 agent만

# 하나의 agent의 컨테이너만 업데이트
openclaw sandbox recreate --agent alfred

왜 필요한가요?

문제: 샌드박스 Docker 이미지 또는 구성을 업데이트할 때:

  • 기존 컨테이너는 이전 설정으로 계속 실행됩니다
  • 컨테이너는 24시간의 비활성 후에만 정리됩니다
  • 정기적으로 사용되는 agent는 이전 컨테이너를 무기한 실행 상태로 유지합니다

해결책: openclaw sandbox recreate를 사용하여 이전 컨테이너를 강제로 제거합니다. 다음에 필요할 때 현재 설정으로 자동으로 재생성됩니다.

팁: 수동 docker rm보다 openclaw sandbox recreate를 선호하세요. Gateway의 컨테이너 네이밍을 사용하고 scope/session key가 변경될 때 불일치를 방지합니다.

구성

샌드박스 설정은 ~/.openclaw/openclaw.jsonagents.defaults.sandbox에 있습니다 (agent별 재정의는 agents.list[].sandbox에):

{
  "agents": {
    "defaults": {
      "sandbox": {
        "mode": "all",                    // off, non-main, all
        "scope": "agent",                 // session, agent, shared
        "docker": {
          "image": "openclaw-sandbox:bookworm-slim",
          "containerPrefix": "openclaw-sbx-"
          // ... 더 많은 Docker 옵션
        },
        "prune": {
          "idleHours": 24,               // 24시간 idle 후 자동 정리
          "maxAgeDays": 7                // 7일 후 자동 정리
        }
      }
    }
  }
}

참고