|
| 1 | +# Demo 1: Java modernization in a Docker Sandbox |
| 2 | + |
| 3 | +This runbook follows the Demo 1 sequence in |
| 4 | +[`ai-agent-sandboxing.md`](../ai-agent-sandboxing.md). Use two terminals: |
| 5 | +Terminal A for Copilot CLI and Terminal B for inspection. |
| 6 | + |
| 7 | +> [!IMPORTANT] |
| 8 | +> Run this demo in clone mode. Direct mode protects the host operating system, |
| 9 | +> but it gives the agent read-write access to the host working tree. |
| 10 | +
|
| 11 | +## What the demo proves |
| 12 | + |
| 13 | +- Copilot CLI runs inside an isolated microVM. |
| 14 | +- The modernization agent assesses, plans, and executes the Java upgrade. |
| 15 | +- The agent works in a private clone and cannot write to the host repository. |
| 16 | +- The sandbox has its own Docker daemon and policy-controlled network access. |
| 17 | + |
| 18 | +## Before you begin |
| 19 | + |
| 20 | +Complete the [Demo 1 environment setup](demo-1-setup.md). Confirm that: |
| 21 | + |
| 22 | +- `sbx`, GitHub CLI, and Git are available. |
| 23 | +- Docker and GitHub authentication succeed. |
| 24 | +- The **Balanced** network policy is active. |
| 25 | +- `uportal-messaging` is clean and checked out on `demo/baseline`. |
| 26 | +- No stale `java-modernize` sandbox contains unpreserved work. |
| 27 | + |
| 28 | +## 1. Start Copilot in a private clone |
| 29 | + |
| 30 | +From the host checkout of `uportal-messaging`, run in Terminal A: |
| 31 | + |
| 32 | +```powershell |
| 33 | +sbx secret set github --command 'gh auth token' |
| 34 | +sbx run --clone --name java-modernize copilot . |
| 35 | +``` |
| 36 | + |
| 37 | +On first use, choose the **Balanced** network preset when prompted. |
| 38 | + |
| 39 | +`--clone` is the important boundary: |
| 40 | + |
| 41 | +- `/run/sandbox/source` is a read-only mount of the host repository. |
| 42 | +- Copilot works in a separate read-write clone inside the microVM. |
| 43 | +- `sbx` adds a `sandbox-java-modernize` Git remote to the host repository. |
| 44 | +- Nothing reaches the host working tree until an explicit fetch, checkout, or |
| 45 | + push. |
| 46 | + |
| 47 | +Copilot's Docker Sandbox template starts with its approval-skipping mode. This |
| 48 | +does not remove the microVM, workspace, credential, Docker daemon, or network |
| 49 | +boundaries. |
| 50 | + |
| 51 | +## 2. Prepare the modernization agent |
| 52 | + |
| 53 | +### Install the plugin |
| 54 | + |
| 55 | +In the Copilot CLI session, enter: |
| 56 | + |
| 57 | +```text |
| 58 | +/plugin marketplace add microsoft/github-copilot-modernization |
| 59 | +/plugin install github-copilot-modernization@github-copilot-modernization |
| 60 | +/plugin list |
| 61 | +``` |
| 62 | + |
| 63 | +Confirm that the list contains: |
| 64 | + |
| 65 | +```text |
| 66 | +github-copilot-modernization@github-copilot-modernization |
| 67 | +``` |
| 68 | + |
| 69 | +The equivalent non-interactive shell commands are: |
| 70 | + |
| 71 | +```bash |
| 72 | +copilot plugin marketplace add microsoft/github-copilot-modernization |
| 73 | +copilot plugin install github-copilot-modernization@github-copilot-modernization |
| 74 | +``` |
| 75 | + |
| 76 | +### Select the orchestrator |
| 77 | + |
| 78 | +Enter `/agent`, then select: |
| 79 | + |
| 80 | +```text |
| 81 | +github-copilot-modernization:modernize |
| 82 | +``` |
| 83 | + |
| 84 | +Do not run the upgrade with the default Copilot agent. The `modernize` agent |
| 85 | +provides the assessment, planning, specialized executors, retries, and |
| 86 | +per-task commits used in this demo. |
| 87 | + |
| 88 | +## 3. Run the modernization |
| 89 | + |
| 90 | +Use this prompt: |
| 91 | + |
| 92 | +```text |
| 93 | +Before making changes, create and switch to a branch named demo/modernized. |
| 94 | +Upgrade this application to Java 21 and Spring Boot 4.1. Assess the current |
| 95 | +application, create a reviewable plan, execute the plan, update tests and build |
| 96 | +configuration, run the relevant Maven verification, check dependencies for |
| 97 | +known vulnerabilities, and commit each completed task separately. Do not push |
| 98 | +the branch or open a pull request. |
| 99 | +``` |
| 100 | + |
| 101 | +The expected workflow is: |
| 102 | + |
| 103 | +1. **Assessment** - discovers Java version, framework, dependencies, and risks; |
| 104 | + writes `.github/modernize/assessment/`. |
| 105 | +2. **Planning** - writes `.github/modernize/<app>/plan.md` and `tasks.json`. |
| 106 | +3. **Execution** - delegates tasks, updates the application, verifies the |
| 107 | + build, and creates detailed task commits. |
| 108 | + |
| 109 | +A specific upgrade prompt can go directly to planning and execution. Asking |
| 110 | +for assessment explicitly keeps all three phases visible for the demo. |
| 111 | + |
| 112 | +## 4. Inspect the sandbox while the agent works |
| 113 | + |
| 114 | +In Terminal B: |
| 115 | + |
| 116 | +```powershell |
| 117 | +sbx ls |
| 118 | +sbx policy ls |
| 119 | +sbx exec -it java-modernize bash |
| 120 | +``` |
| 121 | + |
| 122 | +Inside the sandbox shell: |
| 123 | + |
| 124 | +```bash |
| 125 | +pwd |
| 126 | +node --version |
| 127 | +git branch --show-current |
| 128 | +git status --short |
| 129 | +docker info |
| 130 | +find .github/modernize -maxdepth 3 -type f -print 2>/dev/null |
| 131 | +``` |
| 132 | + |
| 133 | +Show that the host source mount is read-only: |
| 134 | + |
| 135 | +```bash |
| 136 | +touch /run/sandbox/source/__sandbox-write-test |
| 137 | +``` |
| 138 | + |
| 139 | +The command should fail with a read-only filesystem error. Do not use a path |
| 140 | +inside the private clone for this test; the private clone is intentionally |
| 141 | +writable. |
| 142 | + |
| 143 | +Show the isolated Docker daemon without changing the host: |
| 144 | + |
| 145 | +```bash |
| 146 | +docker run --rm hello-world |
| 147 | +docker ps -a |
| 148 | +``` |
| 149 | + |
| 150 | +The container and image exist only in the sandbox's Docker Engine. Docker |
| 151 | +Sandboxes do not mount the host Docker socket. |
| 152 | + |
| 153 | +Exit the inspection shell: |
| 154 | + |
| 155 | +```bash |
| 156 | +exit |
| 157 | +``` |
| 158 | + |
| 159 | +Run `sbx` with no arguments on the host to open the dashboard. Switch to its |
| 160 | +network panel to show allowed and denied outbound connections and the rules |
| 161 | +that made each decision. |
| 162 | + |
| 163 | +## 5. Prove that the host stayed clean |
| 164 | + |
| 165 | +While the agent's commits remain in the private clone, run from the host |
| 166 | +checkout: |
| 167 | + |
| 168 | +```powershell |
| 169 | +git status --short |
| 170 | +git branch --show-current |
| 171 | +git remote --verbose |
| 172 | +``` |
| 173 | + |
| 174 | +Expected result: |
| 175 | + |
| 176 | +- `git status --short` prints nothing. |
| 177 | +- The host remains on `demo/baseline`. |
| 178 | +- A `sandbox-java-modernize` remote is present. |
| 179 | + |
| 180 | +## 6. Verify the result |
| 181 | + |
| 182 | +After the modernization agent finishes, use the inspection shell or ask the |
| 183 | +agent to report: |
| 184 | + |
| 185 | +```bash |
| 186 | +git branch --show-current |
| 187 | +git status --short |
| 188 | +git --no-pager log --oneline --decorate -15 |
| 189 | +find .github/modernize -maxdepth 3 -type f -print |
| 190 | +``` |
| 191 | + |
| 192 | +Confirm that the branch is `demo/modernized`, the expected assessment and plan |
| 193 | +artifacts exist, verification results are reported, and task commits are |
| 194 | +present. |
| 195 | + |
| 196 | +## 7. Preserve evidence and clean up |
| 197 | + |
| 198 | +Continue with |
| 199 | +[Demo 1 validation and recovery](demo-1-validation-and-recovery.md) to: |
| 200 | + |
| 201 | +1. Fetch `sandbox-java-modernize/demo/modernized`. |
| 202 | +2. Review application, build, CI, and modernization artifacts. |
| 203 | +3. Materialize only the reviewed branch on the host. |
| 204 | +4. Stop and remove the sandbox after its work is preserved. |
| 205 | + |
| 206 | +## Troubleshooting |
| 207 | + |
| 208 | +Use the |
| 209 | +[Demo 1 troubleshooting guide](demo-1-validation-and-recovery.md#troubleshooting) |
| 210 | +for plugin installation, Java discovery, network policy, Maven, sandbox mode, |
| 211 | +and fetch failures. |
| 212 | + |
| 213 | +## References |
| 214 | + |
| 215 | +- [Get started with Docker Sandboxes](https://docs.docker.com/ai/sandboxes/get-started/) |
| 216 | +- [Run GitHub Copilot in a Docker Sandbox](https://docs.docker.com/ai/sandboxes/agents/copilot/) |
| 217 | +- [Docker Sandbox isolation](https://docs.docker.com/ai/sandboxes/security/isolation/) |
| 218 | +- [Use Git with Docker Sandboxes](https://docs.docker.com/ai/sandboxes/workflows/git/) |
| 219 | +- [Modernize Java apps with GitHub Copilot modernization](https://learn.microsoft.com/azure/developer/java/migration/github-copilot-app-modernization-for-java-copilot-cli) |
| 220 | + |
| 221 | +Commands and behavior were checked against the linked documentation on |
| 222 | +August 24, 2026. |
| 223 | + |
| 224 | +## Navigation |
| 225 | + |
| 226 | +[Previous: Demo 1 environment setup](demo-1-setup.md) | |
| 227 | +[Next: Demo 1 validation and recovery](demo-1-validation-and-recovery.md) |
0 commit comments