Skip to content

Commit ab5d37b

Browse files
authored
Merge pull request #2936 from pareenaverma/content_review
Docker MCP Toolkit LP review
2 parents d8143b9 + 9bd7906 commit ab5d37b

6 files changed

Lines changed: 164 additions & 100 deletions

File tree

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: The Arm migration challenge and how Docker MCP Toolkit solves it
2+
title: Simplify Arm migration with the Docker MCP ToolKit and Arm MCP Server
33
weight: 2
44

55
### FIXED, DO NOT MODIFY
@@ -8,45 +8,59 @@ layout: learningpathall
88

99
## Why migrate to Arm?
1010

11-
Moving workloads from x86 to Arm64 has become a priority for organizations looking to reduce cloud costs and improve performance. AWS Graviton, Azure Cobalt, and Google Cloud Axion have made Arm-based computing mainstream, offering 20-40% cost savings and improved performance-per-watt for many workloads.
11+
Arm-based cloud instances are now widely available across major providers, including AWS Graviton, Azure Cobalt, and Google Cloud Axion. These platforms deliver strong performance-per-watt characteristics and, for many workloads, measurable cost savings compared to equivalent x86 instances.
1212

13-
The challenge is that migration is not always straightforward. For most containerized applications, rebuilding a Docker image for Arm64 is enough. But when you encounter legacy applications with hand-optimized x86 assembly, AVX2 intrinsics, or architecture-specific compiler flags, the migration becomes significantly more complex.
13+
For containerized applications written in portable, architecture-neutral code, migration can be straightforward: rebuild the container for `linux/arm64` and redeploy.
1414

15-
## What makes x86-to-Arm migration hard?
15+
However, many performance-sensitive applications are not architecture-neutral. They may include:
1616

17-
Traditional migration approaches require:
17+
- x86-specific compiler flags (for example `-mavx2`)
18+
- Hand-optimized assembly
19+
- AVX2 intrinsics mapped directly to Intel vector instructions
20+
- Assumptions about register width, alignment, or instruction semantics
1821

19-
- Manual code analysis for x86-specific dependencies.
20-
- Tedious compatibility checks across multiple tools.
21-
- Researching Arm NEON equivalents for each x86 intrinsic.
22+
In these cases, rebuilding the container is not enough. The source code itself must be adapted for Arm.
23+
24+
## Considerations when migrating from x86 to Arm
25+
26+
When architecture-specific optimizations are present, migration may involve:
27+
28+
- Identifying x86-specific intrinsics or assembly
29+
- Updating compiler flags and build configurations
30+
- Mapping AVX2 operations to appropriate NEON equivalents
2231
- Rewriting vectorized code and adjusting loop structures.
2332
- Updating Dockerfiles, base images, and compiler flags.
24-
- Debugging compilation errors on the new architecture.
33+
- Validating correctness and performance on Arm systems
2534

26-
For a single application with SIMD-optimized code, this can take 5-7 hours of manual work.
35+
These steps are well understood, but they can require careful review across code, build scripts, and container configurations.
2736

2837
## What the Docker MCP Toolkit provides
2938

3039
The Docker MCP Toolkit is a management interface in Docker Desktop that lets you discover, configure, and run containerized MCP (Model Context Protocol) servers. It connects these servers to AI coding assistants through a unified gateway.
3140

3241
For Arm migration, three MCP servers work together:
3342

34-
- **Arm MCP Server**: Provides code scanning (`migrate_ease_scan`), Docker image architecture checking (`check_image`, `skopeo`), Arm knowledge base search (`knowledge_base_search`), and assembly performance analysis (`mca`).
35-
- **GitHub MCP Server**: Enables repository operations including creating pull requests, managing branches, and committing changes.
43+
- **Arm MCP Server**:
44+
Provides migration-focused tools, including:
45+
- `migrate_ease_scan` for detecting x86-specific code and compiler flags
46+
- `check_image` and `skopeo` for verifying container architecture support
47+
- `knowledge_base_search` for a knowledge base of learning resources, Arm intrinsics, and software version compatibility
48+
- `mca` for microarchitectural performance analysis
49+
50+
- **GitHub MCP Server**: Enables Git repository operations including creating pull requests, managing branches, and committing changes.
51+
-
3652
- **Sequential Thinking MCP Server**: Helps the AI assistant break down complex migration decisions into logical steps.
3753

3854
## How AI-assisted migration works
3955

40-
When connected to the Docker MCP Toolkit, an AI coding assistant like GitHub Copilot can execute the entire migration workflow:
41-
42-
1. Use `check_image` or `skopeo` to verify if base images support `linux/arm64`.
43-
2. Run `migrate_ease_scan` on the codebase to find x86-specific code, intrinsics, and compiler flags.
44-
3. Use `knowledge_base_search` to find correct Arm SIMD equivalents for every x86 intrinsic.
45-
4. Convert the code with architecture-specific accuracy.
46-
5. Update the Dockerfile with Arm-compatible base images and compiler flags.
47-
6. Create a pull request with all changes using the GitHub MCP Server.
56+
When connected to the Docker MCP Toolkit, an AI coding assistant like GitHub Copilot can coordinate a structured migration workflow:
4857

49-
What normally takes 5-7 hours of manual work takes about 25-30 minutes.
58+
1. Verify whether container base images support `linux/arm64` using `check_image` or `skopeo`.
59+
2. Scan the codebase with `migrate_ease_scan` to identify AVX2 intrinsics, x86-specific flags, and other portability considerations.
60+
3. Use `knowledge_base_search` to find appropriate Arm SIMD equivalents for every x86 intrinsic.
61+
4. Refactor the code with architecture-specific accuracy.
62+
5. Update Dockerfiles and build configurations for Arm comptibility.
63+
6. Create a pull request with the proposed changes using the GitHub MCP Server.
5064

5165
## What you will build in this Learning Path
5266

@@ -58,8 +72,8 @@ You will:
5872

5973
1. Set up Docker MCP Toolkit with the Arm, GitHub, and Sequential Thinking MCP servers.
6074
2. Connect VS Code with GitHub Copilot to the MCP Gateway.
61-
3. Analyze the legacy x86 codebase to understand what blocks Arm migration.
62-
4. Use AI-driven tools to automate the full migration.
63-
5. Review the pull request created by the AI agent.
75+
3. Analyze the x86-specific portions of the codebase.
76+
4. Use AI-assisted MCP workflows to update intrinsics and container configuration.
77+
5. Review and validate the pull request generated by the AI agent.
6478

6579
In the next section, you will install and configure the Docker MCP Toolkit.

content/learning-paths/servers-and-cloud-computing/docker-mcp-toolkit/2-setup.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ layout: learningpathall
88

99
## Before you begin
1010

11-
You need:
11+
Make sure the following tools are installed:
1212

1313
- Docker Desktop 4.59 or later.
1414
- VS Code with the GitHub Copilot extension.
15-
- A GitHub account with a personal access token.
15+
- A GitHub account with a Personal Access Token(PAT) that allows repository access.
1616
- A machine with at least 8 GB RAM (16 GB recommended).
1717

18+
You will use Docker Desktop to host MCP servers locally, and VS Code with GitHub Copilot to invoke those servers through the MCP Gateway.
19+
1820
## Enable the Docker MCP Toolkit
1921

22+
The MCP Toolkit allows Docker Desktop to run and manage MCP (Model Context Protocol) servers, which expose structured tools that AI assistants can call.
23+
2024
1. Open Docker Desktop.
2125
2. Go to **Settings** > **Beta features**.
2226
3. Toggle **Enable Docker MCP Toolkit** on.
@@ -78,6 +82,14 @@ Open GitHub Copilot Chat in VS Code and ask:
7882
What Arm migration tools do you have access to?
7983
```
8084

81-
You should see tools from all three servers listed. If they appear, your setup is complete.
85+
If the setup is correct, Copilot will list tools from:
86+
87+
- Arm MCP Server
88+
- GitHub MCP Server
89+
- Sequential Thinking MCP Server
90+
91+
This confirms that tool invocation through the MCP Gateway is working.
92+
93+
Your environment is now ready for AI-assisted migration.
8294

83-
In the next section, you will examine the demo application to understand what blocks its migration to Arm64.
95+
In the next section, you will examine the demo application and identify the architecture-specific elements that require adaptation for Arm64.

content/learning-paths/servers-and-cloud-computing/docker-mcp-toolkit/3-understand-the-demo.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@ layout: learningpathall
88

99
## Clone the demo repository
1010

11-
The demo application is a matrix multiplication benchmark written in C++ with AVX2 intrinsics. Clone it:
12-
11+
The demo application is a matrix multiplication benchmark written in C++ using AVX2 intrinsics for vectorized performance on x86 processors.
12+
Clone the repository:
1313
```bash
1414
git clone https://github.com/JoeStech/docker-blog-arm-migration
1515
cd docker-blog-arm-migration
1616
```
17+
This example is intentionally optimized for x86 so that you can see how architecture-specific code appears in practice and how it can be adapted for Arm.
1718

1819
## Examine the Dockerfile
1920

20-
Open the `Dockerfile`. There are two immediate blockers for Arm migration:
21+
Open the `Dockerfile`. There are two areas that require updates for Arm compatibility.
22+
23+
**Add Arm64 support in the base image**: The centos:6 image was published for x86 architecture and does not provide a `linux/arm64` variant. To run on Arm hardware, the base image must support Arm64.
2124

22-
**No Arm64 support in the base image**: The `centos:6` image was built for x86 only. This container will not start on Arm hardware.
25+
Modern multi-architecture base images typically publish both `linux/amd64` and `linux/arm64` manifests. Updating the base image is the first step toward portability.
2326

24-
**x86-specific compiler flag**: The `-mavx2` flag tells the compiler to use AVX2 vector instructions, which do not exist on Arm processors.
27+
**Update compiler flags**: The `-mavx2` flag enables AVX2 vector instructions on x86. Arm processors use different SIMD instruction sets (NEON or SVE), so this flag must be removed or replaced when compiling for Arm.
2528

29+
Here is the full Dockerfile for reference:
2630
```dockerfile
2731
FROM centos:6
2832

@@ -45,12 +49,15 @@ CMD ["./benchmark"]
4549
```
4650

4751
## Examine the source code
48-
49-
Open `matrix_operations.cpp`. The code uses x86 AVX2 intrinsics throughout:
52+
Open `matrix_operations.cpp`. At the top of the file:
5053

5154
```cpp
5255
#include <immintrin.h> // x86-only header
56+
```
57+
The <immintrin.h> header provides Intel SIMD intrinsics, including AVX and AVX2. On Arm systems, SIMD intrinsics are provided through <arm_neon.h> instead.
5358

59+
Inside the matrix multiplication routine, you will see AVX2 intrinsics such as:
60+
```cpp
5461
// Inside the multiply function:
5562
__m256d sum_vec = _mm256_setzero_pd();
5663
__m256d a_vec = _mm256_loadu_pd(&data[i][k]);
@@ -60,27 +67,37 @@ sum_vec = _mm256_add_pd(sum_vec, _mm256_mul_pd(a_vec, b_vec));
6067
__m128d sum_high = _mm256_extractf128_pd(sum_vec, 1);
6168
__m128d sum_low = _mm256_castpd256_pd128(sum_vec);
6269
```
70+
These _mm256_* functions map directly to 256-bit AVX2 instructions.
6371

64-
## Why this code cannot run on Arm
72+
## Architecture considerations for Arm
6573

66-
There are several specific blockers:
74+
To run this code on Arm, several adjustments are required:
6775

68-
1. **x86-exclusive header**: `#include <immintrin.h>` only exists on x86 systems. Arm uses `<arm_neon.h>` instead.
76+
1. **SIMD header replacement**: x86 uses `#include <immintrin.h>`. Arm uses `<arm_neon.h>` instead.
6977

70-
2. **AVX2 intrinsics throughout**: Every `_mm256_*` function is Intel-specific:
71-
- `_mm256_setzero_pd()` creates a 256-bit zero vector (Arm NEON is 128-bit).
78+
2. **Intrinsic mapping**: Each AVX2 intrinsic must be mapped to an Arm equivalent.
79+
For example:
80+
- `_mm256_setzero_pd()` creates a 256-bit zero vector of four doubles(Arm NEON is 128-bit).
7281
- `_mm256_loadu_pd()` loads 4 doubles at once (NEON loads 2 with `vld1q_f64`).
7382
- `_mm256_add_pd()` and `_mm256_mul_pd()` are 256-bit operations (NEON uses 128-bit equivalents).
7483
- `_mm256_extractf128_pd()` extracts the high 128 bits (not needed on NEON).
7584

76-
3. **Vector width mismatch**: AVX2 processes 4 doubles per operation. Arm NEON processes 2 doubles per operation. The entire loop structure needs adjustment.
85+
4. **Vector width differences**: AVX2 operates on 256-bit registers (four double-precision values). NEON operates on 128-bit registers (two double-precision values). This affects:
86+
- Loop stride
87+
- Accumulation logic
88+
- Horizontal reduction patterns
7789

78-
{{% notice Note %}}
79-
SVE/SVE2 on newer Arm cores (Neoverse V1/V2, Graviton 3/4) provides 256-bit or wider vector-length agnostic (VLA) registers, matching or exceeding AVX2 width. The Arm MCP Server knowledge base can help determine the best approach for your target hardware.
80-
{{% /notice %}}
90+
4. **Horizontal reduction logic**: The AVX2 pattern:
8191

82-
4. **Horizontal reduction logic**: The pattern using `_mm256_extractf128_pd` and `_mm256_castpd256_pd128` is x86-specific and must be completely rewritten.
92+
```cpp
93+
_mm256_extractf128_pd(...)
94+
_mm256_castpd256_pd128(...)
95+
```
96+
is specific to x86 register structure. On Arm, reduction is implemented using NEON reduction or pairwise-add instructions instead.
8397
84-
Manual conversion requires rewriting 30+ lines of intrinsic code, adjusting loop strides, and testing numerical accuracy. This is exactly where the Docker MCP Toolkit with the Arm MCP Server becomes essential.
98+
{{% notice Note %}}
99+
On newer Arm platforms supporting SVE or SVE2 (for example Neoverse V1/V2 based platforms), wider vector lengths may be available. SVE uses a vector-length-agnostic (VLA) model, which differs from fixed-width AVX2 and NEON programming. The Arm MCP Server knowledge base can help determine the appropriate approach for your target platform.
100+
{{% /notice %}}
85101
102+
In the next section, you will use GitHub Copilot together with the Docker MCP Toolkit to analyze these elements automatically and generate Arm-compatible updates.
86103
In the next section, you will use GitHub Copilot with the Docker MCP Toolkit to automate the entire migration.

content/learning-paths/servers-and-cloud-computing/docker-mcp-toolkit/4-run-migration.md

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ cd docker-blog-arm-migration
1515
code .
1616
```
1717

18-
Make sure the MCP_DOCKER server is running in VS Code (check **Extensions** > **MCP_DOCKER** > **Start Server** if needed).
18+
Make sure the MCP_DOCKER server is running in VS Code ( Use **Extensions** > **MCP_DOCKER** > **Start Server** if needed).
1919

20-
## Give GitHub Copilot migration instructions
20+
This allows GitHub Copilot to invoke the configured MCP servers through the MCP Gateway.
21+
22+
## Provide migration instructions to GitHub Copilot
2123

2224
Open GitHub Copilot Chat in VS Code and paste the following prompt:
2325

@@ -48,22 +50,24 @@ After completing the migration:
4850
- Include performance predictions and cost savings in the PR description
4951
- List all tools used and validation steps needed
5052
```
53+
This prompt instructs Copilot to use structured MCP tools rather than relying purely on generated suggestions.
5154

52-
## Watch the migration execute
55+
## Observe the migration workflow
5356

54-
GitHub Copilot orchestrates the migration through four phases using the Docker MCP Toolkit.
57+
Copilot now orchestrates the migration using the configured MCP servers. The workflow typically proceeds in several phases.
5558

56-
### Phase 1: Image analysis
59+
### Phase 1: Container Image analysis
5760

58-
Copilot uses the `skopeo` tool from the Arm MCP Server to analyze the base image:
61+
Copilot invokes `check_image` or `skopeo` from the Arm MCP Server:
5962

6063
```text
6164
Checking centos:6 for arm64 support...
6265
```
6366

64-
The tool reports that `centos:6` has no `linux/arm64` build available. This is the first blocker identified. Copilot determines that the base image must be replaced.
67+
The tool reports that `centos:6` has no `linux/arm64` build available. Copilot proposes replacing the base image with a modern multi-architecture alternative.
68+
This step ensures the container can build and run on Arm hardware before addressing source-level changes.
6569

66-
### Phase 2: Code scanning
70+
### Phase 2: Source Code scanning
6771

6872
Copilot runs the `migrate_ease_scan` tool with the C++ scanner:
6973

@@ -77,17 +81,18 @@ The scan detects:
7781
- The `-mavx2` compiler flag in the Dockerfile.
7882
- The x86-specific header `<immintrin.h>`.
7983

80-
Each issue includes the file location, line number, and specific code requiring modification.
84+
Each finding includes file locations and recommended actions. This structured scan avoids manually searching through the codebase.
8185

82-
### Phase 3: Knowledge base lookup and code conversion
86+
### Phase 3: Knowledge base lookup and refactoring code
8387

8488
For each x86 intrinsic found, Copilot queries the Arm MCP Server knowledge base:
8589

8690
```text
8791
Searching knowledge base for: AVX2 to NEON intrinsic conversion
8892
```
8993

90-
The knowledge base returns Arm documentation with the conversions:
94+
The Arm MCP knowledge base provides documented guidance on intrinsic mapping and architecture considerations.
95+
Example mappings:
9196

9297
| x86 AVX2 Intrinsic | Arm NEON Equivalent |
9398
|---------------------|---------------------|
@@ -96,37 +101,46 @@ The knowledge base returns Arm documentation with the conversions:
96101
| `_mm256_add_pd()` | Two `vaddq_f64()` operations |
97102
| `_mm256_mul_pd()` | Two `vmulq_f64()` operations |
98103

99-
The knowledge base also explains that AVX2 uses 256-bit vectors processing 4 doubles at once, while NEON uses 128-bit vectors processing 2 doubles. Loop strides must be adjusted accordingly.
100-
101-
Copilot rewrites the code using this information:
102-
103-
- Replaces `<immintrin.h>` with `<arm_neon.h>` inside `#ifdef __aarch64__` guards.
104-
- Converts the AVX2 loop structure (stride 4) to NEON (stride 2).
105-
- Rewrites the horizontal reduction for NEON.
106-
- Updates the Dockerfile to use `ubuntu:22.04` with `TARGETARCH` for multi-arch builds.
107-
- Changes the compiler flag from `-mavx2` to `-march=armv8-a+simd`.
108-
109-
### Phase 4: Create the pull request
110-
111-
Copilot uses the GitHub MCP Server to create a pull request with:
112-
113-
- All code changes (source files and Dockerfile).
114-
- A detailed description of what was changed and why.
115-
- Performance predictions for Arm.
116-
- A list of all MCP tools used during the migration.
104+
Because AVX2 operates on 256-bit vectors (four doubles) and NEON operates on 128-bit vectors (two doubles), Copilot adjusts:
105+
- Loop stride
106+
- Accumulation logic
107+
- Horizontal reduction pattern
108+
-
109+
The refactoring typically includes:
110+
- Guarding architecture-specific code with #ifdef __aarch64__
111+
- Replacing <immintrin.h> with <arm_neon.h> where appropriate
112+
- Updating compiler flags (for example replacing -mavx2)
113+
- Selecting an Arm-compatible base image such as ubuntu:22.04
114+
- Supporting multi-architecture builds using TARGETARCH
115+
116+
All proposed changes should be reviewed before merging.
117+
118+
### Phase 4: Pull request creation
119+
120+
Once modifications are complete, Copilot invokes the GitHub MCP Server to:
121+
- Create a branch
122+
- Commit changes
123+
- Open a pull request
124+
125+
The PR typically includes:
126+
- Updated Dockerfile
127+
- Refactored source files
128+
- A description of the changes
129+
- A summary of MCP tools used
130+
- Suggested validation steps for Arm hardware
117131

118132
You can see an example PR at [github.com/JoeStech/docker-blog-arm-migration/pull/1](https://github.com/JoeStech/docker-blog-arm-migration/pull/1).
119133

120134
## Summary of changes
121135

122-
The migration produces these key changes:
136+
After migration, you should see:
123137

124-
**Dockerfile**:
138+
**Dockerfile updates**:
125139
- Replaced `centos:6` with `ubuntu:22.04`.
126140
- Added `TARGETARCH` for multi-architecture builds.
127141
- Changed `-mavx2` to `-march=armv8-a+simd` for Arm builds.
128142

129-
**Source code**:
143+
**Source code updates**:
130144
- Added `#ifdef __aarch64__` architecture guards.
131145
- Replaced all `_mm256_*` AVX2 intrinsics with NEON equivalents (`vld1q_f64`, `vaddq_f64`, `vmulq_f64`).
132146
- Adjusted loop strides from 4 (AVX2) to 2 (NEON).

0 commit comments

Comments
 (0)