Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm Version of Docker Image Not Functional Due to Unsupported Base Image #31

Open
MarcOrfilaCarreras opened this issue Feb 5, 2024 · 5 comments

Comments

@MarcOrfilaCarreras
Copy link

Hi guys,

The arm version of the Docker image seems to be encountering issues, possibly stemming from the utilization of the base image "mcr.microsoft.com/dotnet/aspnet," which lacks support for arm architecture.

The logs from the container:

exec /bin/sh: exec format error
exec /bin/sh: exec format error
exec /bin/sh: exec format error
exec /bin/sh: exec format error

I'm using a Raspberry Pi 4, by the way.

@Audiosutras
Copy link

Issue on Raspberry PI 5 as well (aarch64)

@KhaaL
Copy link

KhaaL commented Mar 31, 2024

Thanks for this info, I'm also on arm (aarch64) and running the official compose.yml caused errors for me:

[+] Running 2/0
 ✔ Container librum_db  Running                                                            0.0s 
 ✔ Container librum     Recreated                                                          0.1s 
Attaching to librum, librum_db
librum     | exec /bin/sh: exec format error
librum exited with code 0
librum exited with code 1
librum exited with code 1
librum exited with code 1
librum exited with code 1
librum exited with code 1
librum exited with code 1
librum exited with code 1
librum_db  | 2024-03-31 17:46:31 14 [Warning] Access denied for user 'librum'@'localhost' (using password: YES)
librum exited with code 1
librum_db  | 2024-03-31 17:46:51 15 [Warning] Access denied for user 'librum'@'localhost' (using password: YES)

@xiaket
Copy link

xiaket commented Jul 6, 2024

I digged into this issue a bit, it looks like it is a known issue from this comment. The Presentation.dll binary in the arm64 container is of filetype: Presentation.dll: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows.

However, it looks like mcr.microsoft.com/dotnet/aspnet does support arm64 images:

ubuntu@ubuntu:~$ docker manifest inspect mcr.microsoft.com/dotnet/aspnet
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1580,
         "digest": "sha256:54a062825622483023caafadb465e7873d8fe48454f9ca607bf73b5f51a0016b",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1580,
         "digest": "sha256:2dd1e590b6b8f297ed593272109d0c28272f957d6971e87ea348ea5b531a2a1c",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v7"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1580,
         "digest": "sha256:45c6e36d00122b036d5ab95c167ac4a8dd69a2395d26d4dd3a368bbc09809047",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}
ubuntu@ubuntu:~$ docker image inspect mcr.microsoft.com/dotnet/aspnet:8.0 | jq -r ".[0].Architecture"
arm64
ubuntu@ubuntu:~$ docker image inspect mcr.microsoft.com/dotnet/aspnet:8.0 | jq -r ".[0].RepoDigests[0]"
mcr.microsoft.com/dotnet/aspnet@sha256:72bd33dd8f9829cf9681f0a6bc4b43972ec4860a9560ad2b9f4872b548af0add

I'm able to find the matching image here.

@xiaket
Copy link

xiaket commented Jul 6, 2024

I followed the manual installation instruction on a rpi4(Linux ubuntu 5.4.0-1107-raspi #119-Ubuntu SMP PREEMPT Thu Apr 4 16:03:46 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux), and the generated Presentation.dll is still a 80386 Mono/.Net assembly. So we'll need to change things in dotnet land to make it work on an arm64 machine.

@xiaket
Copy link

xiaket commented Jul 7, 2024

The following patch for Presentation.csproj works if you invoke dotnet publish with -r linux-arm64 flag:

diff --git a/src/Presentation/Presentation.csproj b/src/Presentation/Presentation.csproj
index dfaa402..2ddc5f5 100644
--- a/src/Presentation/Presentation.csproj
+++ b/src/Presentation/Presentation.csproj
@@ -4,6 +4,7 @@
     <TargetFramework>net8.0</TargetFramework>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>disable</Nullable>
+    <RuntimeIdentifiers>linux-arm64</RuntimeIdentifiers>
   </PropertyGroup>

   <ItemGroup>
@@ -17,6 +18,12 @@
     <PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
     <PackageReference Include="AutoMapper" Version="12.0.0" />
     <PackageReference Include="Stripe.net" Version="43.15.0" />
+    <PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
+    <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
+    <PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
+    <PackageReference Include="System.Threading" Version="4.3.0" />
+    <PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
+    <PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
 	<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.10">

The generated file looks like:

ubuntu@ubuntu:~/hack/Librum-Server/src/Presentation$ file bin/Release/net8.0/linux-arm64/Presentation.dll
bin/Release/net8.0/linux-arm64/Presentation.dll: PE32+ executable (console) Aarch64 Mono/.Net assembly, for MS Windows

But then the other generated dlls also need a patch like above(as they are still Intel 80386 Mono/.Net assembly). I know nothing about dotnet so I'll stop now and wait for someone knows better. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants