[英]Docker container on raspberry with linux/arm64
I have the next docker file我有下一个 docker 文件
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Pitman.csproj", ""]
RUN dotnet restore "./Pitman.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Pitman.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Pitman.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Pitman.dll"]
and I'm running the build command:我正在运行构建命令:
docker buildx build --platform linux/arm64 -t latest .
tagging and pushing the image to docker hub标记图像并将其推送到 docker hub
docker tag 8986ff79cb02 myid/pitman:latest
docker push myid/pitman
downloading the image on raspberry pi:在树莓派上下载图像:
sudo docker pull myid/pitman:latest
and when I run the image当我运行图像时
sudo docker run 8986ff79cb02
I get the next error:我收到下一个错误:
standard_init_linux.go:211: exec user process caused "exec format error"
after building the image on my rpi I get this在我的 rpi 上构建图像后,我得到了这个
Step 6/15 : RUN dotnet restore "./Pitman.csproj"
---> Running in 8562957be5d6
standard_init_linux.go:211: exec user process caused "exec format error"
The command '/bin/sh -c dotnet restore "./Pitman.csproj"' returned a non-zero code: 1
what am I missing?我错过了什么?
This is the base image you're using for the final docker image:这是您用于最终 docker 镜像的基本镜像:
mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim
That image only supports amd64 (not ARM).该映像仅支持 amd64(不支持 ARM)。 You need to choose another base image that either supports ARM-only or multi-arch (amd64 + arm64).您需要选择另一个支持 ARM-only 或 multi-arch (amd64 + arm64) 的基础映像。 For example , "latest" and "3.1.8" at time of writing are multi-arch.例如,撰写本文时的“最新”和“3.1.8”是多架构的。
I know for a fact that if you build an image on ARM (with an ARM base image) it will be able to run on any ARM system.我知道一个事实,如果您在 ARM 上构建映像(使用 ARM 基础映像),它将能够在任何 ARM 系统上运行。 I've never done multi-arch builds before, so I don't know if choosing a multi-arch base image, building on amd64, then trying to run on arm64, will work (but based on your comment it sounds like it did).我以前从未做过多架构构建,所以我不知道是否选择多架构基础映像,在 amd64 上构建,然后尝试在 arm64 上运行,是否可行(但根据您的评论,它听起来像)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.