{"id":73,"date":"2026-03-21T22:47:16","date_gmt":"2026-03-21T14:47:16","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/cli-sandbox\/"},"modified":"2026-03-21T23:08:54","modified_gmt":"2026-03-21T15:08:54","slug":"cli-sandbox","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/cli-sandbox\/","title":{"rendered":"\u6c99\u7bb1 CLI"},"content":{"rendered":"<h1>\u6c99\u7bb1 CLI<\/h1>\n<p>\u7ba1\u7406\u57fa\u4e8e Docker \u7684\u6c99\u7bb1\u5bb9\u5668\uff0c\u7528\u4e8e\u9694\u79bb\u667a\u80fd\u4f53\u6267\u884c\u3002<\/p>\n<h2>\u6982\u8ff0<\/h2>\n<p>OpenClaw \u53ef\u4ee5\u5728\u9694\u79bb\u7684 Docker \u5bb9\u5668\u4e2d\u8fd0\u884c\u667a\u80fd\u4f53\u4ee5\u786e\u4fdd\u5b89\u5168\u3002<code>sandbox<\/code> \u547d\u4ee4\u5e2e\u52a9\u4f60\u7ba1\u7406\u8fd9\u4e9b\u5bb9\u5668\uff0c\u7279\u522b\u662f\u5728\u66f4\u65b0\u6216\u914d\u7f6e\u66f4\u6539\u540e\u3002<\/p>\n<h2>\u547d\u4ee4<\/h2>\n<h3><code>openclaw sandbox explain<\/code><\/h3>\n<p>\u68c0\u67e5<strong>\u751f\u6548\u7684<\/strong>\u6c99\u7bb1\u6a21\u5f0f\/\u4f5c\u7528\u57df\/\u5de5\u4f5c\u533a\u8bbf\u95ee\u6743\u9650\u3001\u6c99\u7bb1\u5de5\u5177\u7b56\u7565\u548c\u63d0\u6743\u95e8\u63a7\uff08\u9644\u5e26\u4fee\u590d\u914d\u7f6e\u7684\u952e\u8def\u5f84\uff09\u3002<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw sandbox explain<br \/>\nopenclaw sandbox explain &#8211;session agent:main:main<br \/>\nopenclaw sandbox explain &#8211;agent work<br \/>\nopenclaw sandbox explain &#8211;json<\/p>\n<pre><code>\n### `openclaw sandbox list`\n\n\u5217\u51fa\u6240\u6709\u6c99\u7bb1\u5bb9\u5668\u53ca\u5176\u72b6\u6001\u548c\u914d\u7f6e\u3002\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw sandbox list\nopenclaw sandbox list --browser  # List only browser containers\nopenclaw sandbox list --json     # JSON output\n<\/code><\/pre>\n<p><strong>\u8f93\u51fa\u5305\u62ec\uff1a<\/strong><\/p>\n<ul>\n<li>\u5bb9\u5668\u540d\u79f0\u548c\u72b6\u6001\uff08\u8fd0\u884c\u4e2d\/\u5df2\u505c\u6b62\uff09<\/li>\n<li>Docker \u955c\u50cf\u53ca\u5176\u662f\u5426\u4e0e\u914d\u7f6e\u5339\u914d<\/li>\n<li>\u521b\u5efa\u65f6\u95f4<\/li>\n<li>\u7a7a\u95f2\u65f6\u95f4\uff08\u81ea\u4e0a\u6b21\u4f7f\u7528\u4ee5\u6765\u7684\u65f6\u95f4\uff09<\/li>\n<li>\u5173\u8054\u7684\u4f1a\u8bdd\/\u667a\u80fd\u4f53<\/li>\n<\/ul>\n<h3><code>openclaw sandbox recreate<\/code><\/h3>\n<p>\u79fb\u9664\u6c99\u7bb1\u5bb9\u5668\u4ee5\u5f3a\u5236\u4f7f\u7528\u66f4\u65b0\u7684\u955c\u50cf\/\u914d\u7f6e\u91cd\u65b0\u521b\u5efa\u3002<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw sandbox recreate &#8211;all                # Recreate all containers<br \/>\nopenclaw sandbox recreate &#8211;session main       # Specific session<br \/>\nopenclaw sandbox recreate &#8211;agent mybot        # Specific agent<br \/>\nopenclaw sandbox recreate &#8211;browser            # Only browser containers<br \/>\nopenclaw sandbox recreate &#8211;all &#8211;force        # Skip confirmation<\/p>\n<pre><code>\n**\u9009\u9879\uff1a**\n\n* `--all`\uff1a\u91cd\u65b0\u521b\u5efa\u6240\u6709\u6c99\u7bb1\u5bb9\u5668\n* `--session &lt;key&gt;`\uff1a\u91cd\u65b0\u521b\u5efa\u7279\u5b9a\u4f1a\u8bdd\u7684\u5bb9\u5668\n* `--agent &lt;id&gt;`\uff1a\u91cd\u65b0\u521b\u5efa\u7279\u5b9a\u667a\u80fd\u4f53\u7684\u5bb9\u5668\n* `--browser`\uff1a\u4ec5\u91cd\u65b0\u521b\u5efa\u6d4f\u89c8\u5668\u5bb9\u5668\n* `--force`\uff1a\u8df3\u8fc7\u786e\u8ba4\u63d0\u793a\n\n**\u91cd\u8981\uff1a** \u5bb9\u5668\u4f1a\u5728\u667a\u80fd\u4f53\u4e0b\u6b21\u4f7f\u7528\u65f6\u81ea\u52a8\u91cd\u65b0\u521b\u5efa\u3002\n\n## \u4f7f\u7528\u573a\u666f\n\n### \u66f4\u65b0 Docker \u955c\u50cf\u540e\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n# Pull new image\ndocker pull openclaw-sandbox:latest\ndocker tag openclaw-sandbox:latest openclaw-sandbox:bookworm-slim\n\n# Update config to use new image\n# Edit config: agents.defaults.sandbox.docker.image (or agents.list[].sandbox.docker.image)\n\n# Recreate containers\nopenclaw sandbox recreate --all\n<\/code><\/pre>\n<h3>\u66f4\u6539\u6c99\u7bb1\u914d\u7f6e\u540e<\/h3>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<\/p>\n<h1>Edit config: agents.defaults.sandbox.<em> (or agents.list[].sandbox.<\/em>)<\/h1>\n<h1>Recreate to apply new config<\/h1>\n<p>openclaw sandbox recreate &#8211;all<\/p>\n<pre><code>\n### \u66f4\u6539 setupCommand \u540e\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw sandbox recreate --all\n# or just one agent:\nopenclaw sandbox recreate --agent family\n<\/code><\/pre>\n<h3>\u4ec5\u9488\u5bf9\u7279\u5b9a\u667a\u80fd\u4f53<\/h3>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<\/p>\n<h1>Update only one agent&#8217;s containers<\/h1>\n<p>openclaw sandbox recreate &#8211;agent alfred<\/p>\n<pre><code>\n## \u4e3a\u4ec0\u4e48\u9700\u8981\u8fd9\u4e2a\uff1f\n\n**\u95ee\u9898\uff1a** \u5f53\u4f60\u66f4\u65b0\u6c99\u7bb1 Docker \u955c\u50cf\u6216\u914d\u7f6e\u65f6\uff1a\n\n* \u73b0\u6709\u5bb9\u5668\u7ee7\u7eed\u4f7f\u7528\u65e7\u8bbe\u7f6e\u8fd0\u884c\n* \u5bb9\u5668\u4ec5\u5728\u7a7a\u95f2 24 \u5c0f\u65f6\u540e\u624d\u88ab\u6e05\u7406\n* \u7ecf\u5e38\u4f7f\u7528\u7684\u667a\u80fd\u4f53\u4f1a\u65e0\u9650\u671f\u4fdd\u6301\u65e7\u5bb9\u5668\u8fd0\u884c\n\n**\u89e3\u51b3\u65b9\u6848\uff1a** \u4f7f\u7528 `openclaw sandbox recreate` \u5f3a\u5236\u79fb\u9664\u65e7\u5bb9\u5668\u3002\u5b83\u4eec\u4f1a\u5728\u4e0b\u6b21\u9700\u8981\u65f6\u81ea\u52a8\u4f7f\u7528\u5f53\u524d\u8bbe\u7f6e\u91cd\u65b0\u521b\u5efa\u3002\n\n\u63d0\u793a\uff1a\u4f18\u5148\u4f7f\u7528 `openclaw sandbox recreate` \u800c\u4e0d\u662f\u624b\u52a8 `docker rm`\u3002\u5b83\u4f7f\u7528 Gateway \u7f51\u5173\u7684\u5bb9\u5668\u547d\u540d\u89c4\u5219\uff0c\u907f\u514d\u5728\u4f5c\u7528\u57df\/\u4f1a\u8bdd\u952e\u66f4\u6539\u65f6\u51fa\u73b0\u4e0d\u5339\u914d\u3002\n\n## \u914d\u7f6e\n\n\u6c99\u7bb1\u8bbe\u7f6e\u4f4d\u4e8e `~\/.openclaw\/openclaw.json` \u7684 `agents.defaults.sandbox` \u4e0b\uff08\u6bcf\u4e2a\u667a\u80fd\u4f53\u7684\u8986\u76d6\u8bbe\u7f6e\u5728 `agents.list[].sandbox` \u4e2d\uff09\uff1a\n\n```jsonc  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  &quot;agents&quot;: {\n    &quot;defaults&quot;: {\n      &quot;sandbox&quot;: {\n        &quot;mode&quot;: &quot;all&quot;, \/\/ off, non-main, all\n        &quot;scope&quot;: &quot;agent&quot;, \/\/ session, agent, shared\n        &quot;docker&quot;: {\n          &quot;image&quot;: &quot;openclaw-sandbox:bookworm-slim&quot;,\n          &quot;containerPrefix&quot;: &quot;openclaw-sbx-&quot;,\n          \/\/ ... more Docker options\n        },\n        &quot;prune&quot;: {\n          &quot;idleHours&quot;: 24, \/\/ Auto-prune after 24h idle\n          &quot;maxAgeDays&quot;: 7, \/\/ Auto-prune after 7 days\n        },\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<h2>\u53e6\u8bf7\u53c2\u9605<\/h2>\n<ul>\n<li><a href=\"\/gateway\/sandboxing\">\u6c99\u7bb1\u6587\u6863<\/a><\/li>\n<li><a href=\"\/concepts\/agent-workspace\">\u667a\u80fd\u4f53\u914d\u7f6e<\/a><\/li>\n<li><a href=\"\/gateway\/doctor\">Doctor \u547d\u4ee4<\/a> &#8211; \u68c0\u67e5\u6c99\u7bb1\u8bbe\u7f6e<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6c99\u7bb1 CLI \u7ba1\u7406\u57fa\u4e8e Docker \u7684\u6c99\u7bb1\u5bb9\u5668\uff0c\u7528\u4e8e\u9694\u79bb\u667a\u80fd\u4f53\u6267\u884c\u3002 \u6982\u8ff0 OpenClaw \u53ef\u4ee5\u5728\u9694\u79bb\u7684  [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":368,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions\/368"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}