I am working on a little application that I want to run in a docker container on a Raspberry Pi (Model 4B, 32Bit, 4GB RAM). I am learning Docker currently, so far I have only built and run stuff on my dev machine ( a mac). The container setup and jar work without problems on that machine.
This is my very basic Dockerfile:
FROM java:8
WORKDIR /
ADD my_jar.jar my_jar.jar
EXPOSE 8080
CMD java -jar my_jar.jar
As you can see there is not much going on. I would like to just be able to Docker build . -t myDockerImage on the pi and then run my container. Building succeeds, according to the output, but running fails with an error:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
standard_init_linux.go:219: exec user process caused: exec format error
I did some research, and all I could find was the suggestion to use OpenJDK. Did that, but can't build, it says:
no matching manifest for linux/arm/v7 in the manifest list entries
I looked around on Docker Hub, but it doesn't seem like there is an image for java that fits this architecture. Or maybe I don't know what to look for...?
So how do I get java in a docker container onty this machine (preferrable in a fairly easy, convenient way, but if that doesn't exist, I am happy to do it the hard way, what ever that might entail)?
Btw: This is what lshw states about the RPi:
raspberrypi
description: ARMv7 Processor rev 3 (v7l)
product: Raspberry Pi 4 Model B Rev 1.1
serial: 10000000b3320840
width: 32 bits
capabilities: smp
The problem is that the JRE still depends on the operating system and that depends on the platform architecture. The standard docker image for Java will most likely use a amd64/x64 based Linux OS with the appropriate JDK installed.
Raspberry PI, however, uses the ARM architecture, hence the output ARMv7 Processor rev 3 (v7l).
So you need an ARM-compatible image such as one of those: https://hub.docker.com/r/arm32v7/adoptopenjdk
I'm not sure how compatible ARM v7 and v8 are so I'd suggest you stick to the v7 images :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With