{"id":5320,"date":"2026-11-02T14:08:02","date_gmt":"2026-11-02T14:08:02","guid":{"rendered":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2026\/11\/02\/where-should-your-code-live-in-a-docker-sandbox\/"},"modified":"2026-11-02T14:08:02","modified_gmt":"2026-11-02T14:08:02","slug":"where-should-your-code-live-in-a-docker-sandbox","status":"publish","type":"post","link":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2026\/11\/02\/where-should-your-code-live-in-a-docker-sandbox\/","title":{"rendered":"Where should your code live in a Docker Sandbox?"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Giving an agent a sandbox also means deciding which files it will work on. You can share a checkout from your host, give it a separate working directory for a task, or keep the repository entirely inside the sandbox. Each arrangement changes how you, the human, participate in the work.<\/p>\n<p class=\"wp-block-paragraph\">You might want to watch the diff in your local editor and make changes alongside the agent, or give it room to manage several tasks while you review the results. <code>sbx<\/code> supports both. The way you organize the checkout can change as you ask the agent to take on more of the work.<\/p>\n<h2 class=\"wp-block-heading\">Mounting a repository from your host<\/h2>\n<p class=\"wp-block-paragraph\">Sharing a checkout puts the agent in the working tree you already use. Run <code>sbx run<\/code> from your project directory, and it mounts that directory at the same absolute path inside the sandbox:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: plain; title: ; notranslate\">\n$ cd ~\/my-project\n$ sbx run claude\n<\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">Open a file in your local editor while the agent works on it, and you\u2019ll see changes as they happen. Git works from either side, so you choose whether you want to let the agent make commits or you do it yourself. Development servers on your host can pick up the edits through hot reload, using the runtime and dependencies installed on your host.<\/p>\n<p class=\"wp-block-paragraph\">This fits close collaboration on one task. The coordination cost comes from sharing that working tree: switching branches changes the files the agent sees, and your edits become part of its ongoing work. If you want to switch to something unrelated while the agent continues, you\u2019ll need another checkout.<\/p>\n<p class=\"wp-block-paragraph\"><strong>[!NOTE]<\/strong> Dependencies written into the shared checkout are shared too. Packages with native binaries, such as <a href=\"https:\/\/esbuild.github.io\/getting-started\/#simultaneous-platforms\" rel=\"nofollow noopener\" target=\"_blank\">esbuild<\/a>, may work in the Linux sandbox and fail on a macOS or Windows host. Reinstalling on the host can reverse the problem. Keep separate dependency installations, or run the app consistently in one environment.<\/p>\n<h2 class=\"wp-block-heading\">Give each task a separate working tree<\/h2>\n<p class=\"wp-block-paragraph\">Git worktrees give each task a directory and branch. You can mount each worktree in its own sandbox, while your original checkout remains available for other work. The agent\u2019s edits appear in the worktree. You can inspect either with your local editor and development tools. Each task also gets its own running environment, with tools to prepare and a sandbox and worktree to clean up afterward.<\/p>\n<div class=\"wp-block-ponyo-image\">\n                <img data-opt-id=1964905047  fetchpriority=\"high\" decoding=\"async\" width=\"1999\" height=\"973\" src=\"https:\/\/www.docker.com\/app\/uploads\/2026\/10\/image3-2.png\" class=\"fade-in\" alt=\"image3 2\" title=\"- image3 2\" \/>\n        <\/div>\n<p class=\"wp-block-paragraph\">There is a Git limitation with mounting only a linked worktree. Its <code>.git<\/code> file points to metadata outside the mount, which the agent can\u2019t reach. It can edit files, but checking status, branching, and committing have to happen on the host. The future of software development still needs you to run <code>git status<\/code>.<\/p>\n<p class=\"wp-block-paragraph\">sbx supports a <a href=\"https:\/\/docs.docker.com\/ai\/sandboxes\/workflows\/git\/#clone-mode\" rel=\"nofollow noopener\" target=\"_blank\">clone mode<\/a> that gives the agent a separate checkout with Git available inside the sandbox. You keep your local project, but <code>sbx<\/code> mounts the host source as read-only and creates an independent clone for the agent. Its branch changes and dependency installations stay in its checkout.<\/p>\n<div class=\"wp-block-ponyo-image\">\n                <img data-opt-id=1523938393  fetchpriority=\"high\" decoding=\"async\" width=\"1999\" height=\"1297\" src=\"https:\/\/www.docker.com\/app\/uploads\/2026\/10\/image2-2.png\" class=\"fade-in\" alt=\"image2 2\" title=\"- image2 2\" \/>\n        <\/div>\n<p class=\"wp-block-paragraph\">Bringing the result back becomes a handoff. While the sandbox is running, you can fetch committed branches through the Git remote <code>sbx<\/code> adds on your host. Or the agent can push to the repository\u2019s remote and you can retrieve the branch through your usual Git workflow. Your local editor and development server see the changes after you bring them into your checkout.<\/p>\n<h2 class=\"wp-block-heading\">Keep the project inside the sandbox<\/h2>\n<p class=\"wp-block-paragraph\">A mountless sandbox has no host workspace directory attached. Clone the repository inside it, and the sandbox holds the checkout and its development environment. Your host copy of the project shares no connection with the sandbox checkout.<\/p>\n<div class=\"wp-block-ponyo-image\">\n                <img data-opt-id=1831265097  data-opt-src=\"https:\/\/www.docker.com\/app\/uploads\/2026\/10\/image1-2.png\"  decoding=\"async\" width=\"1999\" height=\"942\" src=\"data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20100%%20100%%22%20width%3D%22100%%22%20height%3D%22100%%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20width%3D%22100%%22%20height%3D%22100%%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E\" class=\"fade-in\" alt=\"image1 2\" title=\"- image1 2\" \/>\n        <\/div>\n<p class=\"wp-block-paragraph\">This workflow resembles working on a remote development machine. Agents connect to the project environment, and you can open a shell with <code>sbx exec<\/code> or connect an editor to the sandbox over SSH. Changes and dependency installations stay separate from your host. To bring work back, you push a branch to the Git remote.<\/p>\n<p class=\"wp-block-paragraph\">One sandbox per project can be a useful mental model here. The project and its tools persist across agent sessions and sandbox restarts. An agent can create worktrees per feature it\u2019s working on, push branches, and create pull requests for review. Starting another task doesn\u2019t require you to prepare another host worktree and sandbox, and the agent has Git access in each working directory. Clone mode supports this internal-worktree approach too.<\/p>\n<p class=\"wp-block-paragraph\">Those tasks share tools and services, so running servers or changing the environment still needs coordination. Separate sandboxes are useful when tasks need independent environments as well as separate files. Branches alone don\u2019t isolate simultaneous edits in one working directory.<\/p>\n<p class=\"wp-block-paragraph\">That independence adds some distance when you want to try the result. Your usual local editor isn\u2019t looking at these files, and a development server running inside the sandbox needs a published port to reach it from your browser.<\/p>\n<p class=\"wp-block-paragraph\">For a web app preview, ask the agent:<\/p>\n<p class=\"wp-block-paragraph\">                  Start the development server on port 8080, bound to <code>0.0.0.0.<\/code><\/p>\n<p class=\"wp-block-paragraph\">Then publish the port from another terminal on the host:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: plain; title: ; notranslate\">\n$ sbx ports my-sandbox --publish 8080:8080\n\n<\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">Open <code>http:\/\/localhost:8080<\/code> in your browser. It\u2019s possible to work interactively this way, but there\u2019s more ceremony than opening a project already on your filesystem.<\/p>\n<p class=\"wp-block-paragraph\">An environment file can make setup repeatable, selecting tools and cloning the repository at creation with something like the community <a href=\"https:\/\/github.com\/docker\/sbx-kits-contrib\/tree\/main\/github-clone\" rel=\"nofollow noopener\" target=\"_blank\">github-clone kit<\/a>. Recreating the sandbox then gives you a fresh environment. Push or copy out work you want to retain first: removing a sandbox deletes files held only there.<\/p>\n<h2 class=\"wp-block-heading\">Choose the repositories for the job<\/h2>\n<p class=\"wp-block-paragraph\">An API change might need a corresponding frontend change, or another repository might provide useful reference material. You can mount several directories into one sandbox, with read-only access for reference repositories. Local editing and previews remain available, but each writable checkout needs branch and change coordination. Task-specific checkouts also leave directories to clean up afterward.<\/p>\n<p class=\"wp-block-paragraph\">A workspace manager such as <a href=\"https:\/\/github.com\/jganoff\/wsp\" rel=\"nofollow noopener\" target=\"_blank\">jganoff\/wsp<\/a> can assemble selected repositories for a task. Mounting that workspace gives the agent the projects it needs together. These are standard clones with their own Git metadata, so the agent retains Git access, unlike a mounted linked worktree.<\/p>\n<p class=\"wp-block-paragraph\">The same scope fits inside a mountless sandbox: clone the repositories needed there and keep the whole workspace in the sandbox. The number of repositories and where their files live are separate choices.<\/p>\n<h2 class=\"wp-block-heading\">Combine the choices to suit the work<\/h2>\n<p class=\"wp-block-paragraph\">The checkout\u2019s location, the sandbox\u2019s lifetime, and the repositories it contains are choices you can combine. You can keep a project sandbox around for many tasks, or mount a workspace assembled for one job. What suits you may change when you want to work more closely with the agent, or give it more room to manage the work itself.<\/p>\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/docs.docker.com\/ai\/sandboxes\/workflows\/git\/\" rel=\"nofollow noopener\" target=\"_blank\">Git workflows documentation<\/a> covers the mechanics of direct mounts, clone mode, and host worktrees.<\/p>\n<p class=\"wp-block-paragraph\">\n<\/p>","protected":false},"excerpt":{"rendered":"<p>Giving an agent a sandbox also means deciding which files it will work on. You can share a checkout from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5321,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[4],"tags":[],"class_list":["post-5320","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/5320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/comments?post=5320"}],"version-history":[{"count":0,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/5320\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media\/5321"}],"wp:attachment":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media?parent=5320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/categories?post=5320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/tags?post=5320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}