{"id":2192,"date":"2026-04-16T22:09:53","date_gmt":"2026-04-16T22:09:53","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/all-things-azure\/?p=2192"},"modified":"2026-04-16T22:10:27","modified_gmt":"2026-04-16T22:10:27","slug":"best-of-both-worlds-for-agentic-refactoring-github-copilot-microvms-via-docker-sandbox","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/all-things-azure\/best-of-both-worlds-for-agentic-refactoring-github-copilot-microvms-via-docker-sandbox\/","title":{"rendered":"Best of Both Worlds for Agentic Refactoring: GitHub Copilot + MicroVMs via Docker Sandbox"},"content":{"rendered":"<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">Legacy codebases frequently contain hardcoded logic and complex build scripts that depend on specific filesystem structures, making them notoriously difficult to modernize in isolated environments. Docker Sandbox addresses this challenge through a bidirectional workspace sync that preserves the same absolute paths inside the sandbox as on the host. This means that when a GitHub Copilot agent refactors a legacy Java or .NET application, file references and build outputs remain consistent across the isolation boundary.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">The result? Modernized code can be moved back to the host without breaking dependencies.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">However, one of the most significant pain points in agentic workflows is the requirement for coding agents to interact with Docker itself. Many agents need to build images, run integration tests in containers, or orchestrate multi-container stacks via docker compose. In a standard container environment, this typically requires mounting the host&#8217;s <span style=\"font-family: 'courier new', courier, monospace;\">\/var\/run\/docker.sock<\/span> into the container &#8211; effectively granting the agent full root-level access to the host Docker daemon. This is a serious security risk: a compromised or misbehaving agent could enumerate all running containers, pull sensitive images, or even escape the sandbox entirely.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">In this blog, we explore the feasibility of using GitHub Copilot alongside isolated runtimes such as Docker Sandbox to modernize legacy applications. Specifically, we walk through containerizing a sample legacy Java application (code available <a href=\"http:\/\/java-migration-copilot-samples\/asset-manager at main \u00b7 Azure-Samples\/java-migration-copilot-samples\">here<\/a>) and preparing it for AI-assisted refactoring, and we demonstrate how these products work together to balance developer productivity with security and isolation.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">Testing containerized legacy code in isolation<\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">A core part of modernizing legacy systems is containerization, or moving monolithic apps into OCI-compliant images. To do this autonomously, an agent must be able to run docker build and docker compose to verify its work. Traditional containers make this risky by requiring access to the host Docker socket. Docker Sandboxes provide a private, isolated Docker daemon within microVM, allowing agents to build and test containerized versions of legacy code without any visibility into or impact on the host&#8217;s primary Docker environment.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">Here\u2019s what a containerization workflow looks like with GitHub Copilot + Docker Sandbox:<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">$ docker sandbox run copilot ~\/asset-manager-mod<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">Creating new sandbox &#8216;copilot-asset-manager-mod&#8217;&#8230;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">copilot: Pulling from docker\/sandbox-templates<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">75ccbb183316: Pull complete<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">5a47b0b23034: Pull complete<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">37e8fa2e5d6f: Pull complete<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">7b336c9714b3: Download complete<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">0bdd8a5ca3bd: Download complete<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">Digest: sha256:4685bd6f84acea2c5017a2a03354cc7c9168334f5b7b1049e5a9e944051797a7<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">Status: Downloaded newer image for docker\/sandbox-templates:copilot<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">\u2713 Created sandbox copilot-sandbox-2026-03-26-160741 in VM copilot-asset-manager-mod<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">\u00a0 Workspace: C:\\Users\\cindywang\\asset-manager-mod<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">\u00a0 Agent: copilot<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">To connect to this sandbox, run:<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">\u00a0 docker sandbox run copilot-asset-manager-mod<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">Starting copilot agent in sandbox &#8216;copilot-asset-manager-mod&#8217;&#8230;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 10pt;\">Workspace: C:\\Users\\cindywang\\asset-manager-mod<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Authentication is being handled through delegation. Within the terminal, type \/login to complete auth via GitHub or GitHub Enterprise.<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/docker-sandbox.webp\"><img decoding=\"async\" class=\"alignleft wp-image-2193 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/docker-sandbox.webp\" alt=\"docker sandbox image\" width=\"624\" height=\"442\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/docker-sandbox.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/docker-sandbox-300x213.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">Mitigate risks during dependency upgrades<\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Modernizing a codebase typically involves updating thousands of unaudited dependencies. The risk of a &#8220;supply chain attack&#8221;, where an agent pulls a malicious package from a public registry, is high. Docker Sandboxes mitigate this through HTTP\/HTTPS filtering proxies that implement a &#8220;smart deny-all&#8221; policy. The sandbox allows the agent to reach essential registries, e.g. npm, PyPI, etc. while blocking access to local networks and cloud metadata endpoints, preventing data exfiltration during high-volume dependency updates.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">In an isolated environment, this can be addressed without too much overhead:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/manage-dependency.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2194 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/manage-dependency.webp\" alt=\"manage dependency image\" width=\"624\" height=\"224\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/manage-dependency.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/manage-dependency-300x108.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">From \u201cperiodic clean-ups\u201d to continuous, high-velocity modernization operations<\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Legacy modernization often requires thousands of repetitive refactoring tasks, such as updating deprecated APIs, converting callbacks to async\/await, or adding error handling. In a standard environment, agents require constant human approval to prevent destructive actions, creating &#8220;approval fatigue&#8221; that bottlenecks the development flow. Docker Sandboxes allow agents to run in &#8220;YOLO mode\u201d, executing commands without permission prompts, because the microVM enforces a hard security boundary that protects the host from accidental data deletion (e.g., rm -rf \/) or malicious code execution.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">The ability to run fleets of agents that perform mass refactoring across thousands of legacy repos at the same time has significant implications in ROI. Today, autonomous agents merge roughly 60% more pull requests than those requiring constant supervision, and at an enterprise-scale, the use of a secure sandbox directly translates into reclaimed developer hours and a reduction in technical debt. This construct allows organizations to move through common modernization scenarios such as rehost, refactor, rearchitect, etc. at a speed that was previously impossible due to manual security review requirements.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Here\u2019s an example of what running fleet (parallel agent executions) looks like in action via Docker Desktop:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet1.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2201 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet1.webp\" alt=\"fleet1 image\" width=\"624\" height=\"141\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet1.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet1-300x68.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet2.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2200 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet2.webp\" alt=\"fleet2 image\" width=\"624\" height=\"245\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet2.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet2-300x118.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet3.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2199 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet3.webp\" alt=\"fleet3 image\" width=\"624\" height=\"221\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet3.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet3-300x106.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet4.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2198 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet4.webp\" alt=\"fleet4 image\" width=\"624\" height=\"239\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet4.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet4-300x115.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet5.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2197 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet5.webp\" alt=\"fleet5 image\" width=\"624\" height=\"228\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet5.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet5-300x110.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet6.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2196 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet6.webp\" alt=\"fleet6 image\" width=\"624\" height=\"172\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet6.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet6-300x83.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet7.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2195 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet7.webp\" alt=\"fleet7 image\" width=\"624\" height=\"237\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet7.webp 624w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/fleet7-300x114.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif; font-size: 12pt;\">Consistency in preserving absolute paths and synchronizing filesystems<\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">A common frustration with virtualized development environments is the disconnect between the host&#8217;s filesystem and the guest&#8217;s view. GitHub Copilot + Docker Sandboxes address this through bidirectional workspace synchronization, where the developer&#8217;s project directory is mounted directly into the sandbox. To ensure compatibility with standard build tools, the sandbox maintains the same absolute path as the host system. If a developer is working in \/Users\/dev\/my-project on macOS, the agent sees the same path inside the MicroVM. This preservation of absolute paths is vital for ensuring that error messages, configuration files, and IDE integrations remain synchronized and coherent across the isolation boundary.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Using vscode as an example:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/filesys.webp\"><img decoding=\"async\" class=\"alignnone wp-image-2202 size-full\" src=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/filesys.webp\" alt=\"filesys image\" width=\"329\" height=\"490\" srcset=\"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/filesys.webp 329w, https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-content\/uploads\/sites\/83\/2026\/04\/filesys-201x300.webp 201w\" sizes=\"(max-width: 329px) 100vw, 329px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Legacy codebases frequently contain hardcoded logic and complex build scripts that depend on specific filesystem structures, making them notoriously difficult to modernize in isolated environments. Docker Sandbox addresses this challenge through a bidirectional workspace sync that preserves the same absolute paths inside the sandbox as on the host. This means that when a GitHub Copilot [&hellip;]<\/p>\n","protected":false},"author":172649,"featured_media":1743,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,19,134,92,109,89],"tags":[],"class_list":["post-2192","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-github-copilot","category-github-copilot-cli","category-modernization","category-platform-engineering","category-thought-leadership"],"acf":[],"blog_post_summary":"<p>Legacy codebases frequently contain hardcoded logic and complex build scripts that depend on specific filesystem structures, making them notoriously difficult to modernize in isolated environments. Docker Sandbox addresses this challenge through a bidirectional workspace sync that preserves the same absolute paths inside the sandbox as on the host. This means that when a GitHub Copilot [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/posts\/2192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/users\/172649"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/comments?post=2192"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/posts\/2192\/revisions"}],"predecessor-version":[{"id":2209,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/posts\/2192\/revisions\/2209"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/media\/1743"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/media?parent=2192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/categories?post=2192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/all-things-azure\/wp-json\/wp\/v2\/tags?post=2192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}