当前位置: 首页 > 知识库问答 >
问题:

运行使用Apple M1芯片(基于ARM的系统)构建的容器时出现“exec格式错误”

段干茂实
2023-03-14

预期行为:我可以运行使用Apple M1芯片构建的容器。

观察到的行为:

假设您有一个Google Cloud Run帐户,并且可以将Docker映像推送到Google容器注册表。我在这个例子中使用https://github.com/seenickcode/trivial-go-api。

  1. `git克隆git@github.com:seenickcode/triple-go-api。git'
  2. cd琐碎go api
  3. docker build-t gcr。木卫一/
Cloud Run error: Container failed to start. 
Failed to start and then listen on the port defined by the PORT environment variable. 
Logs for this revision might contain more information.

日志:

2021-04-02 09:35:40.045 EDT
Cloud Run ReplaceService example hello@redactedforso.com {@type: type.googleapis.com/google.cloud.audit.AuditLog, authenticationInfo: {…}, authorizationInfo: […], methodName: google.cloud.run.v1.Services.ReplaceService, request: {…}, requestMetadata: {…}, resourceLocation: {…}, resourceName: namespaces/myprojectforso-282419/services/example, response: {…}, servi…
Error
2021-04-02 09:35:49.034 EDT
terminated: Application failed to start: Failed to create init process: failed to load /app/main: exec format error
Warning
2021-04-02 09:35:49.174 EDT
Application exec likely failed
Notice
2021-04-02 09:57:43.102 EDT
Cloud Run ReplaceService example hello@redactedforso.com {@type: type.googleapis.com/google.cloud.audit.AuditLog, authenticationInfo: {…}, authorizationInfo: […], methodName: google.cloud.run.v1.Services.ReplaceService, request: {…}, requestMetadata: {…}, resourceLocation: {…}, resourceName: namespaces/myprojectforso-282419/services/example, response: {…}, servi…
Error
2021-04-02 09:57:50.657 EDT
terminated: Application failed to start: Failed to create init process: failed to load /app/main: exec format error

有关我在何处构建映像的系统详细信息:

  • 操作系统:macOS 11.2.3
  • 芯片:苹果M1
  • Docker版本:适用于macOS v3的Docker桌面。3.0(62345)

重要注意事项:

  • 当我使用另一种架构时,这一切对我来说都很好,即通过谷歌容器构建或我的家庭Windows(WSL)桌面
  • 当使用Apple M1芯片构建时,这也不适用于其他代码库,比如我用Rust和Dart编写的另一个项目。似乎与语言无关
  • 我已经使用Google Cloud Run多年了,这个问题是在使用我的带有Apple M1芯片的新笔记本电脑时出现的

共有1个答案

宰父衡
2023-03-14

您正在构建一个与ARM兼容的映像,而谷歌云不支持该映像。

我遇到了一个类似的问题,将Mac M1构建的映像推送到Heroku,我使用buildx并设置预期的平台解决了这个问题

docker buildx build --platform linux/amd64 -t myapp .

我写了一篇媒体文章来解释这个问题,并提出了两个解决方案。

Docker采用多平台设计,可以在不同的架构上运行,但是,图像必须与将要运行的平台匹配。这不是我们的情况。

 类似资料:
  • 我正在尝试不带参数地运行“/home/simulations/scripts/getdsuip . sh”命令。 当我在机器上手动运行这个命令时,效果很好!所以这个文件肯定在那里,肯定是可以运行的(755),并且在同一个用户(root)下。我只在一台机器上看到这个问题,它在其他地方也能工作,但我想弄清楚为什么它会失败。 这会导致以下错误: 我还尝试了其他方法来运行它,结果也是同样的错误: 这是我尝

  • docker错误: PS C:\Windows\System32>docker运行测试错误:出现JNI错误,请检查线程“main”java.lang.noClassDeffounderRorr:javax/JMSException在java.lang.Class.GetDeclaredMethods0(本机方法)在java.lang.Class.GetDeclaredMethods(class.j

  • 我有一个arm模板,可以创建2个文档数据库服务器。ARM模板的部分如下所示: 变量如下所示: 当我运行我的版本时,我得到这个错误(对于两个DocumentDb服务器): 这对我来说毫无意义。我试过用谷歌搜索它,但找不到任何错误的参考。奇怪的是,它创建了资源,并且这些资源是可用的,但部署说它失败了。 以前有人看过这个问题吗?

  • 我正在学习quarkus入门教程,能够生成可执行文件并运行它,但无法运行docker映像。 步骤: > ./mvnw 软件包 -Pnative (它工作) docker build-f src/main/docker/Dockerfile.native-t quokus/get-start.( 泊坞窗运行 -i --rm -p 8080:8080 Quarkus/入门,得到此错误: standar

  • 对于自动构建生成,编写脚本以使用gradle自动生成QT Android构建。 构建步骤在最后一步失败。给出的命令是 C:\Qt\5.10.1\android\u armv7\bin\androiddeployqt。exe——输入C:/Users/user1/Desktop/Sources/Software/build_android/android libTestApp。因此,部署设置。json

  • 本文向大家介绍基于python实现名片管理系统,包括了基于python实现名片管理系统的使用技巧和注意事项,需要的朋友参考一下 本文实例为大家分享了python实现名片管理系统的具体代码,供大家参考,具体内容如下 主程序: 程序工具包: 实现效果: 更多学习资料请关注专题《管理系统开发》。 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持呐喊教程。