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

Apple M1 Silicon能否使用chocolatey容器?运行报错求助

问题:Apple M1 Silicon下Podman运行Chocolatey Linux镜像时Mono崩溃

环境:

  • Apple M1 Silicon (macOS v13.4)
  • Podman v4.2.1

执行任何choco命令时出现Mono断言错误:

* Assertion at ../../mono/arch/amd64/../x86/x86-codegen.h:410, condition `offset == (gint32)offset' not met

用Chocolatey镜像作为基础镜像构建时,出现SIGABRT崩溃:

=================================================================
Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
/usr/local/bin/choco: line 3:     3 Aborted                 (core dumped) mono /opt/chocolatey/choco.exe "$@"

解决方案

1. 完善多架构模拟配置

M1为arm64架构,官方Chocolatey Linux镜像默认是x86_64版本,依赖QEMU模拟运行:

  • 确保qemu-user-static正确配置:
    podman run --rm --privileged docker.io/multiarch/qemu-user-static --reset -p yes
    
  • 运行镜像时明确指定x86_64架构:
    podman run --platform linux/amd64 -it chocolatey/chocolatey bash
    

2. 更新镜像内的Mono版本

旧版Mono在QEMU模拟环境下存在代码生成bug,可通过自定义Dockerfile更新:

FROM chocolatey/chocolatey:latest

# 更新Mono到最新稳定版
RUN apt-get update && apt-get install -y --no-install-recommends mono-devel && rm -rf /var/lib/apt/lists/*

构建镜像后重新测试choco命令。

3. 构建原生arm64版本的Chocolatey镜像

避开架构模拟,直接基于arm64基础镜像构建:

FROM ubuntu:jammy-arm64

# 安装依赖
RUN apt-get update && apt-get install -y --no-install-recommends mono-devel wget unzip && rm -rf /var/lib/apt/lists/*

# 安装Chocolatey
RUN wget https://chocolatey.org/install.sh -O install.sh && \
    chmod +x install.sh && \
    ./install.sh && \
    rm install.sh

ENV PATH="/opt/chocolatey/bin:${PATH}"

构建并运行该原生arm64镜像,无需模拟即可正常使用choco命令。


内容的提问来源于stack exchange,提问作者J. Lockhart

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 19:03:18