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

Raspberry pi: standard_init_linux.go:190: exec user process caused "exec format error" #67

Closed
ghost opened this issue Jun 15, 2018 · 11 comments

Comments

@ghost
Copy link

ghost commented Jun 15, 2018

What do I need to do to get the python3.6 container running on a Raspberrypi 3?

> docker run -it tiangolo/uwsgi-nginx-flask:python3.6 bash -il
standard_init_linux.go:190: exec user process caused "exec format error" 
@tiangolo
Copy link
Owner

Raspberry Pi requires images to be compiled for that architecture, ARM. And although Docker now supports different architectures, and I understand the image format also supports specifying architectures, there's no way to handle it through Docker Hub with the "standard" Docker Hub automated build.

I have already taken several steps (actually some months ago) to make the image, configuration and dependencies compatible with multi-arch (I've worked a lot with Pis). The only step missing is Docker Hub support for automated building images for Raspberry Pi.

For now, I suggest you try cloning this repository in your Pi and building the base image locally. In theory, it should all work. After that, you can run your image normally:

git clone https://github.com/tiangolo/uwsgi-nginx-flask-docker.git
cd uwsgi-nginx-flask-docker/python3.6
docker build -t tiangolo/uwsgi-nginx-flask:python3.6 .

And then run again:

docker run -it tiangolo/uwsgi-nginx-flask:python3.6 bash

I'm not running all those commands right now as I'm typing them here, so it's possible that y put a typo there (so, copy-pasting might not work). Please make sure they are right locally.

And let me know how it goes.

@ghost
Copy link
Author

ghost commented Jun 16, 2018

Thanks for the details! I didn't notice any typos :)
After running the commands you provided, I still get the error during the build process.

git clone https://github.com/tiangolo/uwsgi-nginx-flask-docker.git
cd uwsgi-nginx-flask-docker/python3.6
docker build -t tiangolo/uwsgi-nginx-flask:python3.6 .

Here's the output:

crawforc3@raspberrypi:~/uwsgi-nginx-flask-docker/python3.6 $ docker build -t tiangolo/uwsgi-nginx-flask:python3.6 .
Sending build context to Docker daemon  10.75kB
Step 1/17 : FROM tiangolo/uwsgi-nginx:python3.6
python3.6: Pulling from tiangolo/uwsgi-nginx
cc1a78bfd46b: Pull complete
6861473222a6: Pull complete
7e0b9c3b5ae0: Pull complete
3ec98735f56f: Pull complete
9b311b87a021: Pull complete
048165938570: Pull complete
1ca3d78efb22: Pull complete
0f6c8999c3b7: Pull complete
5a85410f5000: Pull complete
11e507a7a91a: Pull complete
5611adf970c0: Pull complete
6c5a09d7a617: Pull complete
5ef6f86c769f: Pull complete
059ed2525147: Pull complete
6f9071aa3efa: Pull complete
d52de055f099: Pull complete
04b5b5dede06: Pull complete
fbfd0e717f1f: Pull complete
92abf61ca6b6: Pull complete
691d20642c39: Pull complete
b6946f69dc26: Pull complete
Digest: sha256:6c3e3ef68b42530010e57b0d1b6d89921a8a165f2b2adb40eea0af296473721b
Status: Downloaded newer image for tiangolo/uwsgi-nginx:python3.6
 ---> b26e62859311
Step 2/17 : RUN pip install flask
 ---> Running in 9c01a1635fdf
standard_init_linux.go:190: exec user process caused "exec format error"
The command '/bin/sh -c pip install flask' returned a non-zero code: 1

@tiangolo
Copy link
Owner

Oh! Right, sorry, I get what happened.

This image, tiangolo/uwsgi-nginx-flask is based on another one more generic, not customized for Flask, tiangolo/uwsgi-nginx.

That one ( uwsgi-nginx ) is actually based on the official Python 3.6 image (which has a version for Pis), so building that should actually work on a Pi:

git clone https://github.com/tiangolo/uwsgi-nginx-docker.git
cd uwsgi-nginx-docker/python3.6
docker build -t tiangolo/uwsgi-nginx:python3.6 .

After building uwsgi-nginx, you should be able to go again and build uwsgi-nginx-flask, as it is based on uwsgi-nginx, which you will already have locally as you just built it.

cd ../../uwsgi-nginx-flask-docker/python3.6
docker build -t tiangolo/uwsgi-nginx-flask:python3.6 .

@ghost ghost changed the title Rspberry pi: standard_init_linux.go:190: exec user process caused "exec format error" Raspberry pi: standard_init_linux.go:190: exec user process caused "exec format error" Jun 16, 2018
@ghost
Copy link
Author

ghost commented Jun 16, 2018

Thanks for the help! That solves it!

Just for posterity, these are the commands I ran from start to finish for a working build

# Clone and build image that has rpi support

git clone https://github.com/tiangolo/uwsgi-nginx-docker.git
cd uwsgi-nginx-docker/python3.6
docker build -t tiangolo/uwsgi-nginx:python3.6 .

cd ../../

# Clone and build image that is customized for Flask (uses the previous image as the base)

git clone https://github.com/tiangolo/uwsgi-nginx-flask-docker.git
cd uwsgi-nginx-flask-docker/python3.6
docker build -t tiangolo/uwsgi-nginx-flask:python3.6 .

# Run the image 
docker run -it tiangolo/uwsgi-nginx-flask:python3.6 bash

@ghost ghost closed this as completed Jun 16, 2018
@tiangolo
Copy link
Owner

Thanks for reporting back! 🎉

@ghost
Copy link
Author

ghost commented Jun 19, 2018

@tiangolo Do you have any thoughts on how I could package all of this into one Dockerfile?

@tiangolo
Copy link
Owner

Do you mean a single Dockerfile with everything?

If that's the case, I guess that you don't want to have to be building 3 images in each Raspberry Pi for your image to work or something similar. Also, have in mind that once the 2 base images are built on your Pi, you don't have to re-build them again, the images persist in your Docker, inside your Pi. You only need to rebuild your app image.

But if you want to deploy it to several Pis I guess you wouldn't want to compile 3 images each time.

If you are running it on a Raspberry Pi, I imagine it probably won't serve a large scale user base. If that's the case, you could just install uWSGI, without Nginx, and use it directly. Recent versions of uWSGI are supposed to have decent performance without absolutely requiring Nginx. And by discarding Nginx, you no longer need to have 2 processes at the same time, so you no longer need to have a third process to control the other 2 (Supervisord). So you could discard that too. In summary, I think you can try with uWSGI alone and see how it goes. It should be way simpler to set up.

@ghost
Copy link
Author

ghost commented Jun 27, 2018

I suppose, there's no real reason for me to put this on multiple Raspberry Pi's, but sometimes we do things for fun :)

Regardless, I ended up building each base image on a Raspberry Pi and pushing them to dockerhub. This allows me to mirror the way you've setup your Dockerimages and I can pull the two base images, however now they have been built specifically for a Raspberry Pi.

https://hub.docker.com/r/crawforc3/raspberrypi-uwsgi-nginx/
https://hub.docker.com/r/crawforc3/raspberrypi-uwsgi-nginx-flask/

@tiangolo
Copy link
Owner

Ah! Cool! 🐳

@rodrigorodrigues
Copy link

Hi @crawforc3 ,

Would you mind please share your repo for the raspberry pi image you created?

I'm trying to build a multi platform image using Github Action + buildx but the arm64 is not working showing "exec format error".

I'm using tiangolo/uwsgi-nginx-flask:python3.8.

Thanks

@guysoft
Copy link

guysoft commented Aug 18, 2021

I crated a github action that builds arm64 and armf on all containers.For now its pushed to my repo:
tiangolo/uwsgi-nginx-docker#87 (comment)

This issue was closed.
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

3 participants