You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何构建ARM架构Docker Engine二进制文件?dockerd编译异常求助

Fixing ARM64 Docker Daemon (dockerd) Cross-Compilation Issues

Let me break down what’s going wrong with your build process and walk you through how to get a full ARM64 build of all Docker components (including dockerd).

Why Your Current Commands Aren’t Working

The core issue is that your build isn’t properly propagating the ARM64 architecture settings to all components in the Docker CE build pipeline. Here’s what’s happening:

  • The docker client binary is successfully cross-compiled because its build logic directly respects GOOS/GOARCH variables.
  • Components like dockerd, containerd, and runc either rely on precompiled binaries (pulled from upstream) or their sub-build processes aren’t inheriting your architecture flags.
  • Your first attempt used cross-arm which targets 32-bit ARM, not 64-bit ARM (ARM64/aarch64), so that parameter was incorrect. Your second attempt didn’t specify GOARCH=arm64 at all, falling back to the host x86-64 architecture for most components.

Step-by-Step Fix to Build ARM64 dockerd

Follow these steps to ensure all components compile for ARM64:

  1. Clean Existing Build Artifacts
    First, clear any cached x86-64 binaries to avoid mixing architectures:

    make clean
    
  2. Run Cross-Compilation with Explicit Architecture Flags
    Use the static target with explicit GOOS/GOARCH variables, and force compilation of dependent components (instead of using precompiled x86 binaries):

    make static \
      GOOS=linux \
      GOARCH=arm64 \
      DOCKER_BUILD_PKGS=static-linux \
      BUILD_CONTAINERD=true \
      BUILD_RUNC=true
    
    • GOOS=linux GOARCH=arm64: Tells Go and the build system to target ARM64.
    • BUILD_CONTAINERD=true BUILD_RUNC=true: Forces the build pipeline to compile containerd and runc from source for ARM64, instead of pulling prebuilt x86 versions.
  3. Alternative: Use the cross Target
    Docker’s build system has a dedicated cross target for cross-platform builds, which handles most of the architecture setup automatically:

    make cross \
      GOOS=linux \
      GOARCH=arm64
    
  4. Verify the Build Results
    After the build completes, run your file command again to confirm all binaries are ARM64:

    ls | xargs file
    

    All entries should show ARM aarch64 instead of x86-64.

Key Notes for Future Builds

  • Always set GOARCH=arm64 explicitly when targeting 64-bit ARM—cross-arm is for 32-bit ARM (armhf/armv7).
  • Using make clean before cross-compiling prevents cached x86 binaries from being reused accidentally.
  • For static builds, forcing compilation of dependencies like containerd ensures they match your target architecture.

内容的提问来源于stack exchange,提问作者atline

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:20:33