The Python Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands

--

Chapters
00:00 Standard_init_linux.Go:178: Exec User Process Caused &Quot;Exec Format Error&Quot;
01:38 Accepted Answer Score 499
01:49 Answer 2 Score 88
01:59 Answer 3 Score 362
02:16 Answer 4 Score 87
02:43 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