node.js - Docker buildx 与 Apple M1 芯片上的 Node 应用程序 - standard_init_linux.go :211: exec user process caused "exec format error

标签 node.js linux docker apple-m1

请帮忙!
我正在尝试将 docker 镜像部署到 kuebernetes 集群。没问题,直到我切换到带有 M1 的新 Macbook Pro。
在 m1 机器上构建镜像并部署后,我从 kuebernetes pod 收到以下错误:standard_init_linux.go:211: exec user process caused "exec format error"经过一番研究,我关注了this关于获取中的帖子 docker buildx添加并设置。
一旦我使用新的 buildx 构建新镜像并使用 docker 桌面(与 m1 兼容的预览版)在本地运行它,它就可以正常运行。但是 kubernetes pod 仍然显示相同的错误。standard_init_linux.go:211: exec user process caused "exec format error"我的构建命令docker buildx use m1_builder && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 -f Dockerfile -t ${myDockerRepo} --push . '在构建过程中,我看到每个平台都注销了它正在运行来自我的 Dockerfile 的命令。
我的推送命令docker push ${myDockerRepo}需要注意的一件奇怪的事情是 docker push 命令响应中的 sha256 摘要没有改变。
这是我的 docker 文件:

# Use an official Node runtime as a parent image
FROM node:10-alpine

# Copy the current directory contents into the container at /app
COPY dist /app

# Set the working directory to /app
WORKDIR /app

# Make port 8000 available to the world outside this container
EXPOSE 8000

# Run npm run serve:dynamic when the container launches
CMD ["node", "server"]
显然,我不是 Docker 专家。
从满头的头发开始。下降到 3 股。请保存这 3 条线。
我感谢所有的帮助和建议!
更新
我已经将 M1 macbook 构建的镜像拉到我的另一台 macbook 上,并且可以通过 docker 桌面在本地运行该镜像。我不确定这意味着什么。它可能只是一个 kuebernetes 设置吗?

最佳答案

尝试将 --platform=linux/amd64 添加到您的 dockerfile:

FROM --platform=linux/amd64 node:10-alpine

关于node.js - Docker buildx 与 Apple M1 芯片上的 Node 应用程序 - standard_init_linux.go :211: exec user process caused "exec format error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66080348/

相关文章:

node.js - Angular2 内部的 Node 和 Electron 模块

linux - centos 7 : nginx Failed to read PID from file/run/nginx. pid:参数无效

python - 我无法从 Express 应用程序执行 python 脚本

javascript - 如何使用 NodeJS Express 将新创建的 cookie 发送到浏览器

c++ - Linux 和 Windows 下混合 cin 和 getline

python - 如何在终端中的 Jupyter 上运行 python 脚本?

docker - Docker 中的 Virtualbox

docker - 我的Docker容器有几个CPU?

docker - 在 docker-compose run 命令中使用 docker 环境变量

json - Azure CLI 内联参数不起作用