Table of Contents Hide
Docker throws error standard_init_linux.go:228: exec user process caused: exec format error when there are issues with executable file format. It could happen due to these reasons –
- You forgot to put
#!/bin/bashat the top of
- There is a space before shebang (
- Newline character encoding is wrong (
- Architecture mismatch like running
- Script encoding issue –
UTF8 + BOM
Error due to
There are few things regarding shebang.
- There should not be anything before it. Shebang should be the first text in the shell file. Check for spaces, empty lines, hidden characters etc. before it.
- Always include it in the shell files. This proves that the file is executable.
- Use the right command. If it’s a bash file, use
#!/bin/bash, if shell file then use
#!/bin/shand if alpine image then
#. People use to forget it.
Character Encoding (
Character encoding is an underdog which creates a number of issues in coding. This happens due to new line styles of various operating systems. For example –
- Windows uses CRLF (Carriage Return Line Feed). It’s new line is
- Linux uses LF (Line Feed). It’s new line is
When you create codes on Windows, the files uses CRLF encoding. After you deploy them on Linux container it creates encoding issues.
Sometimes this creates standard_init_linux.go:228: exec user process caused: exec format error. So, it’s a good practice to change encoding preferences in your code editors like
LF on Windows.
Architecture Mismatch (
This is the most common issue of exec format error. Take care of these points –
Apple M1 is not of same architecture as of Apple Intel chip. Apple M1 has
AMD64architecture while intel is
- See if you are running 32bit or 64bit operating system.
- You can’t build image on
ARMand run on
Solution is to use
buildx utility of Docker –
# Build for ARM64 docker buildx build --platform=linux/arm64 -t <image-name>:<version>-arm64 . # Build for AMD64 docker buildx build --platform=linux/amd64 -t <image-name>:<version>-amd64 .
Script encoding (
UTF8 + BOM)
Script encoding also seems to be causing issues. Especially on windows systems. So, you will need to check if your executable file is saved as
UTF8+BOM. BOM stands for Byte Order Mark. Generally, UTF8 files works fine.
The above mentioned solutions will surely resolve your error of standard_init_linux.go:228: exec user process caused: exec format. First look for ARM or x86 architecture issue. Check if the image is build for your Docker architecture. Then, if the issue persists, check the shebang. If still it’s not solved, then go with other solutions here.
- Introduction to Kubernetes
- Introduction to Docker, Containers, Images & Repository
- Install and Run Docker Images
- Docker Image – FROM, RUN, COPY, ENTRYPOINT, CMD, EXPOSE explained
- Why docker run or start command not running my container?
- How to list all docker images in system?
- How to list all docker containers?
- How to start/stop a docker container?
- Difference between docker run and docker start
- How to bind docker container port with host?
- How to get logs of docker container?
- How to live stream logs of docker container?
- Set custom name to a docker container
- Access docker container filesystem & terminal
- Getting docker details using docker inspect