2

Description / Reproduction Steps

I am trying to run the opc-ua server examle "server_ctt" (using the open62541 library from here) within a docker container on my Raspberry Pi 1, but I am failing at creating the docker image.

I followed the instructions on here and cloned the repo at first. Afterwards, I try to build the image by executing the following command in the open62541 directory: docker build -f docker/Dockerfile .

This is the output I am getting in the terminal:

pi@raspberrypi:~/ma/dockerVersion/open62541 $ docker build -f docker/Dockerfile                         .
Sending build context to Docker daemon  38.69MB
Step 1/18 : FROM alpine:3.10
3.10: Pulling from library/alpine
4e972d957a60: Pull complete
Digest: sha256:7c3773f7bcc969f03f8f653910001d99a9d324b4b9caa008846ad2c3089f5a5f
Status: Downloaded newer image for alpine:3.10
 ---> cf7ea1e5a972
Step 2/18 : RUN apk add --no-cache cmake gcc git g++ musl-dev mbedtls-dev python py-pip make && rm -rf /var/cache/apk/*
 ---> Running in 82c8b5868509
The command '/bin/sh -c apk add --no-cache cmake gcc git g++ musl-dev mbedtls-dev python py-pip make && rm -rf /var/cache/apk/*' returned a non-zero code: 139

Beforehand, I have installed docker on my raspberry pi using the convenience script here

Any suggestions on how to solve this problem?

Background Information

I am connected to my raspberry pi via PuTTy. But I guess this doesn't make the difference. Furthermore, building the image on Windows and running the server_ctt example works completely fine.

EDIT:

As building/running the open62541 image is working on my windows pc, I have tried to save and copy it to my raspberry pi 1. The docker load command on my raspberry pi was working just fine put running the images outputs following erro:

standard_init_linux.go:211: exec user process caused "exec format error"

This may be due to different architectures (as raspberry pi 1 uses the ARM architecture). How can I solve this?

user7335295
  • 401
  • 2
  • 7
  • 31
  • 1
    Error code 139 usually means Out of Memory. Given that you want to build the image on a Raspberry PI that is very likely to happen. You should build the image on a bigger host and then only run the container on the Raspberry PI. – Mihai Mar 06 '20 at 14:07
  • @Mihai hey! thank you for your suggestion, it seems plausible. What I have tried: I have built and saved the image on my windows pc. Then I have copied the image via WinSCP to my raspberry pi 1 and then I have loaded the image which worked just fine. But if I try to run the image now on my raspberry pi, I get the following error: standard_init_linux.go:211: exec user process caused "exec format error". The reason might be the different architectures (as raspberry pi has an ARM architecture). How can I solve this? – user7335295 Mar 09 '20 at 09:10
  • Try to build the image in a Linux environment. You can start a vagrant machine under windows and build inside your image. – Mihai Mar 09 '20 at 12:32
  • @Mihai I have tried to build it within a ubuntu virtual machine and I get the same error code there too. Is there a way to cross-compile the image for the raspberry pi (arm architecture)? – user7335295 Mar 10 '20 at 06:40
  • 2
    Not really. You will need to find a base image that supports arm (example: https://hub.docker.com/r/arm64v8/alpine/) and rebuild your image based on it. The image you are using is based on alpine:3.10. Most probably you will need to tweak some other things as well but this is where I'd start. – Mihai Mar 10 '20 at 06:48
  • @user7335295 Can you run `free -m` and tell us how much swap space you have? – Vahid Mar 14 '20 at 14:48

1 Answers1

1

To answer the updated question: You can build for your Raspberry Pi with the experimental docker buildx command.

This will create some virtualized builders that will build your container for the desired architectures. As such, the build process can take much longer (I think a factor of 10 is realistic for my projects).

The most important command for your case would be something like

docker buildx build --platform linux/arm/v7 .
Stefan
  • 2,460
  • 1
  • 17
  • 33