Docker makes it easy to package an application and run the same image across different environments. The problem starts when the machines running those containers use different CPU architectures.
An application developed on an ARM64 laptop may work perfectly on that machine but fail when the same Docker image is deployed to an x64 server. The reverse can happen when an image is built on an x64 CI runner and later deployed to an ARM64 environment.
The application code may be identical. The difference is the CPU architecture used by the container image.
For modern development environments, supporting both ARM64 and x64 is increasingly useful. Developers may use ARM-based laptops, while CI systems, cloud virtual machines, and existing servers may still use x64 infrastructure.
The practical solution is to build a multi-platform Docker image.
This article explains the architecture differences, how Docker handles multi-platform images, how to build them from a .NET application, and the common problems that appear when native dependencies are involved.
ARM64 and x64 Are Different Architectures
The two architectures use different instruction sets.
ARM64 is commonly found in:
ARM-based laptops
Cloud ARM instances
Mobile and embedded devices
Development boards
x64, also called amd64, is common on:
Traditional Intel servers
AMD servers
Many CI runners
Existing cloud infrastructure
A Docker image built specifically for one architecture is not automatically compatible with another.
For example:
Application Image
|
+---- linux/amd64
|
+---- linux/arm64These are different image variants.
Docker can present them under one image tag using a multi-platform manifest.
What Is a Multi-Platform Image?
A multi-platform image contains references to different platform-specific image manifests.
For example:
myapp:latest
|
+---- linux/amd64
|
+---- linux/arm64When an ARM64 machine pulls the image:
docker pull myapp:latestDocker selects the ARM64 variant.
When an x64 machine pulls the same tag, Docker selects the x64 variant.
The application developer does not need to maintain separate image names such as:
myapp-amd64
myapp-arm64Instead, one logical image tag can represent multiple architectures.
Why a Normal Docker Build Can Cause Problems
Consider this Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:latest
WORKDIR /app
COPY ./publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]If this image is built on an x64 machine:
docker build -t myapp .the resulting image can be architecture-specific.
Moving it to an ARM64 machine may result in an error similar to an architecture mismatch.
The important distinction is:
Dockerfile
|
v
Build environment architecture
|
v
Image architectureThe Dockerfile itself does not automatically make the output multi-platform.
Check the Architecture of Your Current Machine
Before troubleshooting, check the host architecture:
docker versionYou can also inspect the system:
uname -mTypical output may look like:
x86_64or:
aarch64Docker can also report the architecture of an image:
docker image inspect myappFor a more convenient inspection of a published image:
docker buildx imagetools inspect myapp:latestA multi-platform image should show entries for the architectures it supports.
Use Docker Buildx
Docker Buildx provides the tooling needed to build images for multiple platforms.
A typical command is:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t myregistry.example.com/myapp:latest \
--push .The important option is:
--platform linux/amd64,linux/arm64It tells Docker to build variants for both architectures.
The result is one image tag with multiple platform-specific manifests.
Why --push Matters
A multi-platform build normally needs to be pushed to a registry so the registry can store the platform-specific manifests and layers.
For example:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t myregistry.example.com/myapp:1.0 \
--push .After pushing, an ARM64 machine can pull the same tag:
docker pull myregistry.example.com/myapp:1.0Docker selects the appropriate image.
An x64 machine can use the exact same command.
Build a .NET Application for Multiple Architectures
A simple multi-stage .NET Dockerfile might look like this:
FROM mcr.microsoft.com/dotnet/sdk:latest AS build
WORKDIR /src
COPY ["MyApp/MyApp.csproj", "MyApp/"]
RUN dotnet restore "MyApp/MyApp.csproj"
COPY . .
WORKDIR "/src/MyApp"
RUN dotnet publish \
"MyApp.csproj" \
-c Release \
-o /app/publish \
--no-restore
FROM mcr.microsoft.com/dotnet/aspnet:latest AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]The important point is that the base images also need to support the target architectures.
If the .NET SDK and runtime images provide both ARM64 and x64 variants, Buildx can select the correct image during the build.
The application image then inherits the appropriate architecture.
Build for Both Platforms
With the Dockerfile in place:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t myregistry.example.com/myapp:latest \
--push .You can inspect the result:
docker buildx imagetools inspect \
myregistry.example.com/myapp:latestThe output should contain platform entries for both:
linux/amd64
linux/arm64Test Each Architecture
Building an image is not enough.
You should test the image on every supported architecture.
If you have an ARM64 development machine:
docker run --rm myregistry.example.com/myapp:latestDocker should select the ARM64 variant.
On an x64 machine, the same command should select the x64 variant.
You can also explicitly request a platform:
docker run \
--platform linux/amd64 \
--rm \
myregistry.example.com/myapp:latestAnd:
docker run \
--platform linux/arm64 \
--rm \
myregistry.example.com/myapp:latestThis is useful for testing from a machine that does not physically use the target architecture.
Emulation Is Useful, But It Is Not the Same as Native Testing
Docker can use emulation to build or run an image for another architecture.
For example, an ARM64 machine can build an x64 image through emulation.
This is convenient, but emulation has limitations.
Builds can be slower, and applications with architecture-specific native components may behave differently.
A good workflow is:
Local development
|
v
Build multi-platform image
|
v
CI validation
|
+---- ARM64 test
|
+---- AMD64 test
|
v
Registry
|
v
DeploymentFor important production workloads, native CI runners or native test environments can provide better confidence.
Native Dependencies Are the Difficult Part
Pure managed .NET code is generally easier to move between architectures.
The situation changes when the application depends on native libraries.
Examples include:
Database client libraries
Image processing libraries
Compression libraries
Cryptography libraries
Browser automation dependencies
System-level packages
Native Node.js modules
Custom C or C++ libraries
A package may work on x64 but not provide an ARM64 build.
For example:
Application
|
+---- Managed .NET code
|
+---- Native library
|
+---- x64 onlyThe ARM64 image can build successfully and still fail at runtime.
Watch Out for Architecture-Specific Package Installation
A Dockerfile may contain:
RUN apt-get update && \
apt-get install -y some-native-packageThat package needs to exist for the architecture being built.
With multi-platform builds, Docker executes the build for each target architecture.
Therefore:
linux/amd64 -> package for amd64
linux/arm64 -> package for arm64If the package is unavailable for ARM64, the ARM64 build can fail.
Do not assume that because a package exists in one architecture's repository, it exists in another.
Avoid Hard-Coded Architecture Paths
Some native tools install files into architecture-specific locations.
Code such as:
COPY native/x64/libexample.so /usr/lib/will obviously not work for an ARM64 image.
A multi-platform build should either:
Use architecture-neutral packages.
Install the correct architecture-specific package.
Build the native dependency for the target platform.
Use separate build stages where architecture-specific logic is required.
Docker exposes platform information that can be used when necessary.
For example:
ARG TARGETARCH
RUN echo "Building for $TARGETARCH"Possible values include:
amd64
arm64You can use that value carefully when selecting architecture-specific dependencies.
Be Careful With uname During Cross-Platform Builds
One common mistake is using:
RUN uname -mto decide which architecture is being built.
With emulation, the result may represent the environment in a way that does not match the target platform you intended.
Docker Buildx provides build arguments such as:
ARG TARGETARCH
ARG TARGETOSThese describe the target platform.
For example:
RUN echo "Target OS: $TARGETOS"
RUN echo "Target architecture: $TARGETARCH"This is generally a better basis for architecture-specific build logic.
Keep Build and Runtime Images Consistent
Multi-stage builds should use compatible architecture variants.
For example:
FROM mcr.microsoft.com/dotnet/sdk:latest AS buildfollowed by:
FROM mcr.microsoft.com/dotnet/aspnet:latest AS runtimeworks when both base images provide the required target platforms.
Avoid manually mixing an ARM64 runtime with x64 native binaries copied from another stage.
The architecture must remain consistent across the final runtime image.
Platform-Aware Docker Compose
Local development sometimes requires testing a specific architecture.
Docker Compose can specify a platform:
services:
api:
image: myregistry.example.com/myapp:latest
platform: linux/amd64This can be useful when an ARM64 developer needs to reproduce an x64 production environment.
However, remember that emulation can affect performance.
Do not use emulated performance as a direct benchmark for production.
CI/CD for Multi-Platform Images
A CI pipeline should build both architectures and publish the resulting image.
A simplified GitHub Actions workflow can look like this:
name: Build Docker Image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: myregistry.example.com/myapp:latestThe important part is:
platforms: linux/amd64,linux/arm64The pipeline produces one logical image tag containing both platform variants.
Use Image Tags Carefully
A multi-platform image works best when the tag represents the application version rather than a machine architecture.
For example:
myapp:1.4.0can contain:
linux/amd64
linux/arm64Avoid forcing users to choose:
myapp:1.4.0-amd64
myapp:1.4.0-arm64unless there is a specific operational reason.
The registry manifest allows Docker to select the correct image automatically.
Compare Common Build Approaches
Approach | ARM64 Support | x64 Support | Suitable for Production |
|---|---|---|---|
Standard | Depends on builder | Depends on builder | Yes, for one platform |
Buildx single platform | Yes | Yes | Yes |
Buildx multi-platform | Yes | Yes | Yes |
Emulated cross-build | Yes | Yes | Useful, but validate carefully |
Separate architecture tags | Yes | Yes | Works, but more operational work |
For most applications that need both architectures, a Buildx multi-platform image is the simplest operational model.
Common Mistakes
Building on ARM64 and assuming the image works on x64
The Dockerfile may build successfully while producing an ARM64-specific image.
Always inspect the published image manifest.
Building only one platform in CI
A local ARM64 build does not automatically create an x64 image.
Explicitly specify:
--platform linux/amd64,linux/arm64Ignoring native dependencies
Managed code may be portable while a native dependency is not.
Check every native library used by the application.
Using architecture-specific binaries without checking the target
A copied .so, executable, or native package may work on one architecture and fail on another.
Testing only the build
A successful build does not prove runtime compatibility.
Run the image for both target platforms.
Depending entirely on emulation
Emulation is useful for development and CI, but native testing provides better confidence for performance-sensitive or native-heavy applications.
Using different application versions for each architecture
This can create subtle production differences.
Keep the application source and release version aligned across architectures.
Troubleshooting Architecture Errors
Error: exec format error
This usually indicates that a binary was built for a different architecture.
Check:
docker image inspect myappand:
docker buildx imagetools inspect myapp:latestThen verify that the host and image architectures match.
ARM64 build fails while x64 succeeds
Look for:
Native packages
Architecture-specific binaries
Shell scripts downloading x64 tools
Native NuGet dependencies
External command-line utilities
Also inspect the Docker build logs for the failing stage.
Application starts but crashes at runtime
The image itself may be valid while a native dependency is incompatible.
Check the runtime logs and inspect installed native libraries.
Multi-platform build is very slow
Possible causes include:
Emulation
Large build contexts
Missing Docker layer caching
Rebuilding dependencies unnecessarily
Compiling native code
Use BuildKit caching and keep the Docker build context small.
Production Recommendations
A reliable multi-platform Docker workflow should follow a few principles.
Build once and publish one multi-platform tag
Use Buildx to create both architecture variants.
Test both architectures
Do not assume that a successful x64 build proves ARM64 compatibility.
Keep native dependencies visible
Document native libraries and verify that every supported architecture has a compatible build.
Use target platform variables when necessary
Prefer Docker's target architecture information over assumptions based on the build host.
Keep Dockerfiles deterministic
Avoid downloading architecture-specific binaries without verifying checksums and target architecture.
Monitor the final image
Inspect the manifest after publishing:
docker buildx imagetools inspect \
myregistry.example.com/myapp:latestMake this part of CI validation when multi-platform support is important.
Advantages and Disadvantages
Advantages
One image tag can support multiple architectures.
Developers can use ARM64 machines without maintaining separate application releases.
x64 production environments can continue using the same image tag.
Cloud ARM instances become easier to support.
CI and deployment workflows become more consistent.
Docker automatically selects the correct platform image.
Disadvantages
Builds take longer than single-platform builds.
Native dependencies require additional testing.
Emulation can complicate development and CI.
Multi-platform CI requires more build configuration.
Architecture-specific bugs can remain hidden if only one platform is tested.
The extra work is mostly in the build and testing pipeline. Once the image is published correctly, deployment becomes much simpler.
A Practical Multi-Platform Workflow
A good development workflow looks like this:
Developer Machine
|
v
Dockerfile
|
v
Buildx
|
+------------+
| |
v v
linux/amd64 linux/arm64
| |
+-----+------+
|
v
Registry
|
v
Same Image Tag
|
+-----+------+
| |
v v
x64 ARM64
Server ServerThe architecture-specific work happens during image creation.
The deployment process can remain architecture-neutral.
Conclusion
Supporting both ARM64 and x64 does not require maintaining two separate application releases.
Docker's multi-platform image support allows one image tag to contain architecture-specific variants. When an ARM64 or x64 machine pulls that image, Docker selects the appropriate variant automatically.
The important part is making sure the application and everything inside the container actually supports both architectures.
For .NET applications that mostly use managed code, the transition is often straightforward. Native dependencies are where most of the additional work appears. Libraries, command-line tools, operating system packages, and custom native binaries all need to be checked.
Build the image with Buildx, publish both linux/amd64 and linux/arm64 variants, test each platform, and inspect the final image manifest.
Once that workflow is part of CI, developers can work on ARM64 machines while production continues to run on x64 infrastructure without maintaining separate Docker images or deployment processes.

Join the conversation! Your thoughts help the community grow.