Open Mik4sa opened 3 years ago
@Mik4sa Can you elaborate on the steps to produce a working image for armv7? Thank you
Of course I can. It's fairly easy though.
Inside of the dockerfile change the base image for the SDK. Change it from mcr.microsoft.com/dotnet/core/sdk:3.1
to mcr.microsoft.com/dotnet/core/sdk:3.1-buster
(for .NET 5 it would be mcr.microsoft.com/dotnet/sdk:5.0-buster-slim-amd64
) and create and push the image with buildx. For example:
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t baget:multi-arch --push .
I just tested it on master. The build completed without any errors (I didn't tested it at runtime, but should work). Atleast the arm/v7 (x86) should work. I used it some months ago (though with a slighty different dockerfile).
The reason why you need to use a different tag for the SDK is, that the SDK isn't available for arm (not sure if for both or just for arm/v7 (x86)). Afaik without changing the tag, docker would try to pull the image for arm, which doesn't exist
If you just need a quick solution, check out this: https://github.com/Mik4sa/BaGet/blob/master/Dockerfile-arm32v7 This is what I used. It's tested and worked fine so far. Just use the normal docker build command, if you prefer the second. That's not multi-arch though. Just arm/v7
Thanks for the fast reply.
I tried it on my raspberrypi and on my windows 10 machine.
Using your provided dockerfile and running docker buildx build --platform linux/arm/v7 -t baget-arm .
. Neither work, the raspberrypi just dies (looses ssh connection, and needs to be restarted by hand) and my windows machine returns
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c dotnet restore BaGet]: exit code: 131
Did you configured buildx before? You can read about it here: https://docs.docker.com/desktop/multi-arch/#build-and-run-multi-architecture-images
docker buildx ls
generates for me:
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
multi-arch-builder * docker-container
multi-arch-builder0 npipe:////./pipe/docker_engine running linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
default docker
default default running linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
If you don't you basically need to run these commands before and just once:
docker buildx create --name multi-arch-builder --use
(or any name you like)docker buildx inspect --bootstrap
Now it should work.
No I did not configure buildx before. Im quite new to all this docker stuff :D. Thanks for you patience.
I ran your suggested commands and get the same output for docker buildx ls
:
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
multi-arch-builder * docker-container
multi-arch-builder0 npipe:////./pipe/docker_engine running linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
default docker
default default running linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
When I run the command docker buildx build --platform linux/arm/v7 -t baget-armv7 --push .
I get an error:
#9 [build 2/7] RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
#9 sha256:9dde81f9499d53b4286efa9655ae8af7b520db2172565d3d978777f8aef9f783
#9 0.082 standard_init_linux.go:219: exec user process caused: exec format error
#9 ERROR: executor failed running [/bin/sh -c curl -sL https://deb.nodesource.com/setup_10.x | bash -]: exit code: 1
------
> [build 2/7] RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -:
------
Dockerfile:6
--------------------
4 |
5 | FROM --platform=linux/arm/v7 mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
6 | >>> RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
7 | RUN apt-get install -y nodejs
8 | WORKDIR /src
--------------------
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c curl -sL https://deb.nodesource.com/setup_10.x | bash -]: exit code: 1
Looks like you are mixing the solutions. Only use the buildx command if you are using the base image mcr.microsoft.com/dotnet/core/sdk:3.1-buster
for the build step.
In case you are using my dockerfile from my fork use the normal docker build command, so something like this: docker build -t baget-armv7 .
And since it's the normal build command you would need to push it then.
Side note: I used/tried the buildx solution yesterday on a windows 10 machine.
Great it works on my windows machine now! However when pushing the image to docker hub and pulling it on my pi I get the following warning:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
Why is that? Didn't I just build for arm?
Which solution did you used now? The one with buildx or the one I used in my fork?
Buildx
Hmm maybe you should try the other one, this is tested. I'm sorry, I didn't pulled the build image on my pi yesterday, just build.
Are you sure, that you pulled the right image (and maybe not the original)? I just tested it again and this time I also pulled and run it. For me it's working.
Weird... well it wouldn't suprise me if I messed up somewhere. I've seen you're from Germany too, do you mind hopping on a quick discord session and sorting this out :) ? I would highly appreciate it. My discord is: TheBata#1043
Just so that everyone else knows. The buildx solution is indeed working. We got it running on his raspi. I guess that he just accidentally pushed the wrong image to the registry.
Has the arm image been pushed to a docker registry?
No, only local, yet.
I have the same problem with my .net6 app. I tried a bunch of things which i reverted again. Currently I have this docker file: https://github.com/pkuehnel/SmartTeslaAmpSetter/blob/fix/rpiSupport/Plugins.SmaEnergymeter/Dockerfile
Current state is, that I get the following error on my build action:
#38 [linux/arm/v7 build 4/7] RUN dotnet restore "Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj"
#38 0.140 A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders
#38 ERROR: process "/dev/.buildkit_qemu_emulator /bin/sh -c dotnet restore \"Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj\"" did not complete successfully: exit code: 131
I already tried using the 6.0-bullseye-slim-amd64
(newest commit) but now I get the following error:
> [linux/arm64 build 4/7] RUN dotnet restore "Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj":
#38 0.085 .buildkit_qemu_emulator: /bin/sh: Invalid ELF image for this architecture
------
./Plugins.SmaEnergymeter/Dockerfile:11
@Mik4sa Could you give me a clue how I could resove this problem?
@pkuehnel This doesn‘t have anything to do with this issue nor with BaGet itself, right? If so, please create an issue or something like this in your repo and contact me there. Let’s continue your problem there. I try to have a real look at it tomorrow
For reference: https://github.com/pkuehnel/SmartTeslaAmpSetter/issues/42
A build for linux/arm64
arch would also be great so that it is runnable on M1 Mac.
A build for
linux/arm64
arch would also be great so that it is runnable on M1 Mac.
@jwosty Do you mean something like this? https://hub.docker.com/layers/bagetter/bagetter/latest/images/sha256-07014e1be769fcbc116f018c1b59a45e9d8c5e470d5f6f2e011a7c950e00d396?context=explore
Is your feature request related to a problem? Please describe.
I would like to run BaGet on my raspberry pi. Currently it's running the official Raspberry Pi OS which is 32 bit. So I would need an image for the armv7 architecture.
Describe the solution you'd like
I guess the best would be a multi arch image. In case you don't know about it you can read here about it: https://docs.docker.com/docker-for-mac/multi-arch/
Describe alternatives you've considered
Ofcourse I can clone master and build it myself, but this should not be the way to go. There might be others wanting this. An official supported image would be way better.
Additional context
I already tried that on my local machine. I build a test image for armv7 and started it on my raspberry pi. Building and starting was fine. I could reach the instance without any problems. I haven't tried anything else though. But since .NET and Nodejs support multi arch itself there shouldn't be any (big) problems.
In case you consider an multi arch image. You may also want to build for armv8, which is the 64 bit version of arm.
I can test the armv7 images for you if you need help with it. Just concat me.