Moby: panic: exec format error

Created on 5 May 2013  路  4Comments  路  Source: moby/moby

Using Docker to run the following command:

docker run -i -t -p 8000 amrabed/webserver /bin/bash < start

works normally. However,

docker run -i -t -p 8000 amrabed/webserver /webserver/start

(same script within the docker image) generates the following error:

panic: exec format error

goroutine 1 [running]:
github.com/dotcloud/docker.executeProgram(0x7fff8baf8f43, 0x7fff00000010, 0xf84007f0a0, 0x100000001, 0x6b5d2c, ...)
/build/buildd/lxc-docker-0.2.1/src/github.com/dotcloud/docker/sysinit.go:78 +0x1bc
github.com/dotcloud/docker.SysInit()
/build/buildd/lxc-docker-0.2.1/src/github.com/dotcloud/docker/sysinit.go:101 +0x247
main.main()
/build/buildd/lxc-docker-0.2.1/src/github.com/dotcloud/docker/docker/docker.go:25 +0x60

goroutine 2 [syscall]:
created by runtime.main
/usr/lib/go/src/pkg/runtime/proc.c:221

goroutine 3 [syscall]:
os/signal.loop()
/usr/lib/go/src/pkg/os/signal/signal_unix.go:20 +0x1c
created by os/signal.init路1
/usr/lib/go/src/pkg/os/signal/signal_unix.go:26 +0x2f

Most helpful comment

fwiw i've seen this error message when given command script had a broken shebang, like #/bin/bash instead of #!/bin/bash

All 4 comments

fwiw i've seen this error message when given command script had a broken shebang, like #/bin/bash instead of #!/bin/bash

@svenfuchs you create a file with a broken shebang in a container, you commit it and you have a panic when you try to run it ?

Just wanted to confirm that this is exactly the issue I was having and fixing the shebang to be on the first line with no spaces around it solved it.

Separate: On the possibility that others have the same issue I did, which is a generated .sh file which had a preceeding blank line, this line of code will remove blank lines.

sed -i '/^\s*$/d' outdir/main.sh -- this requires gnu-sed. If you're on mac, brew install gnu-sed and the command will be gsed instead.

@vieux sorry, i've missed your question before.

so, yes, that's what i've seen ("panic: exec format error" on running a script with a broken shebang as a command). i've just mentioned it here for others who might find this through google, like i did.

Was this page helpful?
0 / 5 - 0 ratings