buildah: exec user process caused "exec format error" when run container with CMD on RHEL
Download below two files to a directory and build an image from it.
https://github.com/docker-library/hello-world/tree/master/amd64/hello-world https://github.com/docker-library/hello-world/blob/master/amd64/hello-world/hello
on RHEL 7.4, it throws an error as below. No this error on Fedora 27.
# buildah bud -t testing/hello .
STEP 1: FROM scratch
STEP 2: COPY hello /
STEP 3: CMD ["/hello"]
STEP 4: COMMIT containers-storage:[overlay@/var/lib/containers/storage+/var/run/containers/storage:overlay.override_kernel_check=true]docker.io/testing/hello:latest
# buildah images
IMAGE ID IMAGE NAME CREATED AT SIZE
f4ff539da64e docker.io/testing/hello:latest Feb 13, 2018 08:27 3.699 KB
# buildah from docker.io/testing/hello
hello-working-container
# buildah run hello-working-container
standard_init_linux.go:190: exec user process caused "exec format error"
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 39 (12 by maintainers)
just adding #!/bin/bash to my entry point file fixed the issue.
Turns out the #!/bin/bash was in my entry point file, but since I did a copy and paste into that file, the first line was a newline, not the #!/bin/bash, effectively ignoring it. If this helps anyone as well. Deleted the empty line and all worked fine.
We build with an wrong architecture…
CGO_ENABLED=0 GOOS=linux GOARCH=amd64
and then: go build -o bin/serviceXYZ_linux_amd64
Our Image is for godeployment and we get this error. Maybe it will help somebody…
@gouyang Make sure if there is a shebang in
hello.Though I’m not familiar with go, I happen to find here since I met with the same problem (
standard_init_linux.go:190: exec user process caused "exec format error").I think it is because the system does not know how to execute the file. FYI: What’s the appropriate Go shebang line?
Also be aware of the difference between the shell form and exec form of
CMDin Dockerfile.For anyone who got a
standard_init_linux.go:190: exec user process caused "no such file or directory"error after applying this fix, you’re probably on an alpine base image which does not come with bash.Replacing
#!/bin/bashwith#!/bin/shwill do the trick!In case anyone finds this useful, you can get this issue if your shell script uses CRLF for line endings and/or UTF-8 with BOM (e.g. if you created a shell script file in Visual Studio). Changing to LF only and straight UTF-8 fixed it for me.
@limup Podman is a related project to Buildah. It lives under the libpod project at: https://github.com/containers/libpod and has it’s own website https://podman.io. In short, it’s a OCI compliant container system.
buildah runemulates what happens with theRUNcommand in a Dockerfile.podman runis the equivalent of the clidocker runcommand. In fact you can alias podman for docker and it should be gtg on your system. For more details, please see this blog: https://developers.redhat.com/blog/2018/11/20/buildah-podman-containers-without-daemons/