The Python Oracle

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

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Bleepage Open

--

Chapters
00:00 Question
02:12 Accepted answer (Score 473)
02:28 Answer 2 (Score 314)
02:47 Answer 3 (Score 183)
03:33 Answer 4 (Score 85)
03:47 Thank you

--

Full question
https://stackoverflow.com/questions/4249...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #linux #bash #docker

#avk47



ACCEPTED ANSWER

Score 499


I forgot to put

#!/bin/bash

at the top of the sh file, problem solved.




ANSWER 2

Score 362


This can happen if you're trying to run an x86 built image on an arm64/aarch64 machine.

You'll need to rebuild the image using the corresponding architecture




ANSWER 3

Score 88


Add this code

#!/usr/bin/env bash

at the top of your script file.




ANSWER 4

Score 87


If the Docker image is built on an M1 chip and uploaded to be deployed by Fargate then you’ll notice this container error in Fargate:

standard_init_linux.go:228: exec user process caused: exec format error

There’s a couple ways to work around this. You can either:

  • Build your docker image using:
docker buildx build --platform=linux/amd64 -t image-name:version .
  • Update your Dockerfile’s FROM statements with
FROM --platform=linux/amd64 BASE_IMAGE:VERSION