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

M1芯片Mac构建Docker镜像缺失Linux x86依赖库如何解决

问题复现

报错日志如下:

Starting: "docker" exec -i 737ff06a8ab3 /bin/sh -c "ID=.; if [ -e /etc/os-release ]; then . /etc/os-release; fi; if [ $ID = alpine ] && [ -e /remote_debugger/linux-musl-x64/vsdbg ]; then VSDBGPATH=/remote_debugger/linux-musl-x64; else VSDBGPATH=/remote_debugger; fi; $VSDBGPATH/vsdbg --interpreter=vscode --interpreter=vscode"
Error from pipe program 'docker': qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
报错根因

这是M1芯片Mac的ARM64架构与x86_64架构容器不兼容导致的问题:第二次运行时调用的vsdbg调试器为x86_64版本,在ARM架构的容器环境下缺少x86运行时依赖,触发qemu转译失败报错。

解决方案
  • 方案1:强制指定容器使用ARM64架构(优先推荐)
    在Dockerfile开头的基础镜像声明中添加平台参数:

    FROM --platform=linux/arm64 <你的原基础镜像名>
    

    如果你使用docker-compose启动服务,在对应服务的配置段中添加架构指定:

    services:
      <你的服务名>:
        platform: linux/arm64
        # 其余配置保持不变
    

    该方案会拉取ARM原生架构的镜像,vsdbg也会自动匹配ARM版本,不会触发转译错误。

  • 方案2:为容器安装x86运行时依赖(适用于必须使用x86镜像的场景)
    如果你的业务必须依赖x86架构的镜像,可以在Dockerfile中添加x86兼容库的安装步骤:

    • Debian/Ubuntu系基础镜像:
    RUN dpkg --add-architecture amd64 && apt update && apt install -y libc6:amd64
    
    • Alpine系基础镜像:
    RUN apk add libc6-compat gcompat
    
  • 方案3:清理构建缓存后重新构建
    首次运行正常、第二次报错大概率是缓存了x86架构的中间层镜像,先执行命令清理构建缓存:
    docker builder prune
    重新构建时添加无缓存参数即可:
    docker build --no-cache -t <你的镜像名> .

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.29 04:15:04