简体   繁体   English

带有 linux/arm64 的树莓派上的 Docker 容器

[英]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.

相关问题 Docker 和 ARM64 - 无法加载文件或程序集 - Docker and ARM64 - Could not load file or assembly Windows ARM (arm64) 上的 SqlServerTypes - SqlServerTypes on Windows ARM (arm64) 带有 asp.net 核心二进制文件 x86_64 的 bitbake 嵌入式 linux docker 容器 - bitbake embedded linux docker container with asp.net core binaries x86_64 错误本机链接错误:找不到架构arm64的IOSurface框架 - Error Native linking error: framework not found IOSurface for architecture arm64 如何在没有源代码的情况下将.ipa或.app的体系结构从arm64更改为i386 - How to change architecture of .ipa or .app from arm64 to i386 without source code 无法从UWP打包项目(UWP + Win32)构建ARM64 - Unable to build for ARM64 from UWP packaging project (UWP + Win32) 如何检测我们是否在.NET中的Windows 10的ARM64版本下运行? - How to detect we're running under the ARM64 version of Windows 10 in .NET? 如何在带有 ARM64 的笔记本电脑上编译 c# dotnet 5 隔离 function 应用程序 - How to compile a c# dotnet 5 isolated function app on notebook with ARM64 如何在 Windows 11 ARM64 上使用 VS Code 调试 C# 控制台应用程序? - How to debug C# console app with VS Code on Windows 11 ARM64? .net 核心应用程序在 linux docker 容器中解析小数 - .net core app parsing decimals in a linux docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM