Docker 映像在 Intel mac 上运行,但不在 M1 mac 上运行 [英] Docker image runs on Intel mac but not M1 mac

查看:60
本文介绍了Docker 映像在 Intel mac 上运行,但不在 M1 mac 上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在 Docker 容器中运行的 Java Spring Boot 应用程序.它基于 openjdk:13-jdk-alpine.我们将它部署到 Linux 机器上,但我们也能够在 Windows 机器以及基于 Intel 的 iMac 上本地运行它.

We have a Java Spring Boot application that runs in a Docker container. It is based on openjdk:13-jdk-alpine. We deploy it to Linux machines, but we are also able to run it locally on Windows machines, as well as on an Intel-based iMac.

不过,我们发现它无法在基于 ARM 的 MacBook Pro 上正常运行.我们得到的异常是基本的 Java 错误,例如找不到符号 Java.class[]",以及其他看起来像 JVM 关闭的东西.

We have found, though, that it cannot run properly on an ARM-based MacBook Pro. The exceptions we get are basic Java errors like "Can't find symbol Java.class[]," and other things that look like the JVM is off.

有没有办法构建一个适用于所有这些平台的 Docker 镜像,包括 M1 MacBook Pro?

Is there a way to build a Docker image that will work on all these platforms, including the M1 MacBook Pro?

推荐答案

使用 构建您的图像multiarch 支持以摆脱未来所有可能的架构故障.为了干净利落地做到这一点,请避免在 Dockerfile 中使用与平台相关的任何内容,老式的 Dockerfile 就可以了.

Build your images with multiarch support to get rid of all possible architecture failures in the future. To do this cleanly, avoid using anything related to the platform in your Dockerfile, just old-school Dockerfiles are ok.

如果你使用 github 和 github-actions,你可以查看 this 来构建您的图像并将它们推送到您的图像存储库中.这也可用于构建在 RaspberryPi 上运行的映像,如 SBC.

If you are using github and github-actions, you may check this to build your images and push them into your image repository. This can be also used for building images which work on RaspberryPi like SBCs.

这篇关于Docker 映像在 Intel mac 上运行,但不在 M1 mac 上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆